「複雑な」データの配列をListViewにマップしたいと思います。非常に単純化された形式では、私のデータモデルは次のようになります。
class ListPlacesValues {
String idObject;
String name;
String city;
String country;
ArrayList<String> classification;
double distance_quantity;
DistanceUnit distance_unit;
[...more stuff ...]
}
複雑なデータをHashListに変換してから、SimpleAdapterを使用できることはわかっています。
SimpleAdapter mAdapter = new SimpleAdapter(
this,
hashList,
R.layout.places_listitem,
new String[] { "name", "city", "country"},
new int[] { R.id.name, R.id.city, R.id.country}
);
ただし、データモデルを直接使用したいのですが、どこからどのように開始すればよいかわからないため、最終的には次のようなことができます。
ArrayList<ListPlacesValues> values = getData();
MyAdapter mAdapter = new MyAdapter(
this,
values,
R.layout.places_listitem,
ListPlacesValues { values.name, values.city, values.country},
new int[] { R.id.name, R.id.city, R.id.country}
);
解決策:このAndroid APIサンプル(List14)を見つけました。これは非常に役に立ちました。