My events management app has two types of views in the list view : a small simmple text view for not-so-important events and a complex view created with a FrameLayout
Due to the view recycling in Android, it may happen that the convertView returned to me is recycled from the simpler view and I now have to display the larger view.
Not if you override getViewTypeCount() and getItemViewType() in your adapter.
In your case:
getViewTypeCount()
would return 2
getItemViewType()
would return 0 or 1, where you return 0 for those positions that are one type of row, and return 1 for those positions that return the other type of row
Then, you are guaranteed that if convertView
is not null
, it is a row of the proper type.