Month ago I first saw ResourceCursorAdapter being used in Android development.
That gave me enough curiosity to summarize them all in a single place.
That gave me enough curiosity to summarize them all in a single place.
There are several types which differ by data source and manipulation complexity available to the user. Lets start...
Simple adapter implementation used for ListView. You provide data by overriding required methods that provide elements for the list. Mostly used for simple list implementations.
SimpleAdapter
Very useful adapter that allows us to map data to elements in the layout file. You provide a grid (two same sized arrays) which tells which element goes into which place and map that contains all the data needed for this grid to know what to put where.
ArrayAdapter
For me less convenient than the SimpleAdapter since default behavior is to map String array elements to single text field. You can override it and provide an array of complex object which have data to populate more complex rows.
SimpleCursorAdapter
An easy adapter to map columns from a cursor to elements defined in the layout file. You can specify which columns you want, which views you want to display the columns, and the layout file that defines the appearance of these views.
CursorAdapter
More sofisitcated implementation of the SimpleCursorAdapter which is abstract so its up to you
to create views with cursor providing you the data from database.
ResourceCursorAdapter
Very similar to CursorAdapter. Doesn't have a newView method which makes it more appropriate
for not so complex views.
SpinnerAdapter
Haven't used this one that much but from what I've seen enables you to define two views, one with data and the second dropdown with choices.
SimpleCursorTreeAdapter
The following two are my most favorite. They allow us to define list elements together with the groups they belong in. Very convenient for situations where you need list with grouped data. You provide both child and group views with appropriate data binding
CursorTreeAdapter
Same as previous but with more liberty and requirements. Better for complex lists.
HeaderViewListAdapter
ListAdapter used when a ListView has header views. This ListAdapter wraps another one and also keeps track of the header views and their associated data objects.
WrapperListAdapter
Haven't seen this one before. Haven't seen any examples but it seems it wraps another list adapter. Strange...
Well that's all I thing....
Now I have them all in single place so I don't have to look around. Sweet :)
Nice copy/paste of the documentation ..
ReplyDeleteSo what?
DeleteThis is good answer.
Thanks for sharing (Y) ..Must cover ExpandableListAdapter & SimpleExpandableListAdapter also..:)
ReplyDeleteThank you!
ReplyDeleteWhat adapter is more appropriate for nested listview? thanks
ReplyDeleteI think ExpandableListAdapter should do the trick
ReplyDeleteThank you!
ReplyDeletenice info and some of them even new for me. i have never even heard about it.
ReplyDeleteThanks.
Thank You For Sharing :)
ReplyDeleteThanks for sharing about list of android adapter..Android Training in chennai
ReplyDeleteHappy to see this blog i got the solution wat i needed Android Training
ReplyDelete