タイプ の次の HashMap を作成し、次のようにHashMap<String, List<String>>
値を追加しています。
ListView lv = (ListView)findViewById(R.id.list);
HashMap<String, List<String>> hm = new HashMap<String, List<String>>();
List<String> values = new ArrayList<String>();
for (int i = 0; i < j; i++) {
values.add(value1);
values.add(value2);
hm.put(key, values);
}
データを取得し、ListAdapter に解析してから ListView に解析したいと考えています。これは、リストビューの xml です。
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
リスト項目の xml:
<!-- for the key value -->
<TextView
android:id="@+id/id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<!-- For Value 1 -->
<TextView
android:id="@+id/value1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<!-- For Value 2 -->
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
hashMap からデータを取得し、それを ListAdapter に入れ、ListView に設定するにはどうすればよいですか?