2011-06-28 20 views
1

私のリストアイテムのそれぞれにテンプレートが続く行レイアウトを作成しようとしていました。現在私はこれを持っており、各リストに1行のテキストを表示することができます。私は私がこのような画像ボタンや複数のテキストフィールドとして複数の項目を追加できるようにそれを変更しようとすると、Android XMLレイアウトの問題

<?xml version="1.0" encoding="utf-8"?> 
<TextView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:textSize="20sp" 
    android:padding="100dp" > 
</TextView> 

しかし、それは常に私をコンパイルすることはできません。

私はdeveloper.androidのウェブサイト上のチュートリアルからのXMLの一部を取ってみました、

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<TextView android:id="@+id/text1" 
    android:textSize="16sp" 
    android:textStyle="bold" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 

<TextView android:id="@+id/text2" 
    android:textSize="16sp" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 
</LinearLayout> 

しかし、それは私というエラースロー - 処理命令のターゲットマッチング「[XX] [mm]の[のLL] "は ではありません。 - エラー:XMLを解析中にエラーが発生しました:エンティティの開始時にXMLまたはテキスト宣言がありません

誰かがこれを手伝ってくれますか?私はこのエラーが何を意味するかについてはあまりよく分かりません。

UPDATE:私が何をしようとしています何

は、項目のリストを示し、右側のサイドバーのようなフラグメントを持つことで、私が掲示最初のXMLで、私が得ることができますよ私は欲しいと思っていますが、私はそれを変更することはできませんでした。

package com.project.test; 

import android.app.ListFragment; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.View; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 

public class TestListFragment extends ListFragment { 

    String [] Items = {"Item A", "Item B", "Item C"}; 

    @Override 
    public void onActivityCreated(Bundle savedInstanceState) { 
     super.onActivityCreated(savedInstanceState); 
     setListAdapter(new ArrayAdapter<String>(getActivity(), 
       R.layout.listtemplate, Items)); 
    } 

    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) { 
     Log.i("FragmentList", "Item clicked: " + id); 
    } 
} 
+0

「XMLの最初の行を開始する前に、すべての空白を削除すると、」あなたの質問を更新しないでしたそれを完全に別のものにしてください。 Madsの回答は100%正しいので、今は冗長です。あなたはそれに答えてマークして、新しい質問を開始するべきでした。 – Blundell

答えて

2

LinearLayoutの開始タグがないためかもしれませんか?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

<TextView android:id="@+id/text1" 
    android:textSize="16sp" 
    android:textStyle="bold" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 

<TextView android:id="@+id/text2" 
    android:textSize="16sp" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 
</LinearLayout> 
+0

あなたの返事をありがとう、これは、エラーをスローすることからxmlを解決しますが、今これはなぜそうですか? –

+0

こんにちは、簡素化、私はかなり例外は、XMLファイルとは何の関係もないことを確認します。しかし、それを貼り付けてみるとわかります。 –

+0

あなたのご援助ありがとう、私はフラグメント内のコードで質問を更新しました。 –

21

あなたはこの解決策を信じていないだろう...私は同じ問題を持っていたと答えが

+1

+1 XML宣言の前に実際にコメントが挿入されています(<! - Some Comment-- >それは私の場合の問題で、linearLayoutの終了タグがありません – AgentKnopf

+1

私はあなたを信じています:) – Vaibs

関連する問題