Reputation: 118822
I am going to make a grid of images and I am trying to figure out whether to use an array adaptor or a baseadaptor. While the GridView example, stores the data in an array, it uses a BaseAdapter rather than a ArrayAdaptor. I am curious why this is. One thing I noticed about an ArrayAdapter, is that its constructor takes a textViewResourceId
for some unknown reason - although the documentation say the getView can be used to make it work with other kinds of views as well. So, if I want a fixed grid of images for a menu, which class would you recommend choosing?
Upvotes: 18
Views: 9533
Reputation: 1006869
You typically choose your adapter class based on what the model data is. If you have an ArrayList
of objects, use ArrayAdapter
. If you have a Cursor
from a database query, use a CursorAdapter
. BaseAdapter
can be used for anything, but it requires more coding, since it has no innate knowledge of how to iterate over the data.
Upvotes: 48