Android LayoutInflater を使い始めたので、助けが必要です。
次の XML で定義されたレイアウトを使用する ListActivity があります。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
この ListView には、次のように別の XML をインフレートして各行を生成する ArrayAdapter が含まれています。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/item_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="20dip"
android:textColor="#FFF"
/>
<ImageView
android:id="@+id/item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="6dip"
android:src="@drawable/example_icon"
/>
</LinearLayout>
</LinearLayout>
これは正常に機能していますが、今はアイテムごとに可変数のアイコンを表示したいと考えています (そのため、ListView の各行は、TextView の下に異なる数の ImageView を持つことができます)。
アイコンのリスト用に別の XML を定義し、入れ子になったレイアウトから ListView を構築する必要があるのではないでしょうか? これを行うためのより良い方法はわかりません。助言がありますか?
ありがとうございました!
編集: これは、私がやろうとしていることの例です: http://tinypic.com/r/2s9yniw/7