Using a SimpleAdapter
If we want more control over the parts of the data to be rendered and how the data is rendered for each item, we can use a different adapter and different item templates.
How to do it...
List views allow us to entirely customize each item view through item templates. Android has a few predefined templates that we can use:
We can make use of the simple, single-line text items using the
ArrayAdapter<T>
type and a simple string collection:var adapter = new ArrayAdapter<string>( this, Android.Resource.Layout.SimpleListItem1, data);
Android also provides a means to handle more complex data. To do this, we use a collection of the
JavaDictionary<string, object>
objects:var data = new JavaList<IDictionary<string, object>>();
We can add items to this list like any other collection using the
Add()
method:data.Add(new JavaDictionary<string, object> { { "name", "Bruce Banner" }, { "status", "Bruce Banner feels like SMASHING!" } });
With more...