Android - Listview Adapter With Items Of Two Views
Solution 1:
You can subclass BaseAdapter and utilize the following methods:
getViewTypeCount()
should return the number of different row types your adapter supports. getItemViewType()
is where you implement the "decision" of which view type a particular row should have. If, for example, getViewTypeCount()
returns 3, then getItemViewType()
method should return 0, 1, or 2.
You can use this inside of getView to inflate/create a different layout for different row types.
EDIT:
Since it's a custom adapter, you can implement it in whatever way makes sense for your data. If you can create a data structure that works for what you want, then just make the adapter able to work with that. In the worst case, you might just have an array (or list) of Objects and have to use instanceof
to do the decision work.
Post a Comment for "Android - Listview Adapter With Items Of Two Views"