I would like to display an array of "complex" data in a ListView. In a very simplified form, my data model will look something like this:
class ListPlacesValues { String idObject; String name; String city; String country; ArrayList<String> classification; double distance_quantity; DistanceUnit distance_unit; [...more stuff ...] }
I know that I can convert my complex data to a HashList and then just use the 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} );
However, I would prefer to use my data model directly, but I don’t know where and how to start, so in the end I can do something like this:
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} );
Solution: I found this Android API example ( List14 ), which was really useful.
source share