I\'m using an extended version of BaseAdapter based on the EfficientAdapter example from the SDK demo samples.
My data is basically an object (ListPlaces
You forgot a couple of methods you need to override: getViewTypeCount() and getItemViewType(). These are not needed for lists where all rows are the same, but they are very important for your scenario. Implement these properly, and Android will maintain separate object pools for your headers and detail rows.
Or, you could look at:
Thanks to the hint with getViewTypeCount() and getItemViewType() it works perfectly now.
Implementing these two methods was very simple:
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public int getItemViewType(int position) {
if(listPlaces.getValues().get(position).separator >= 0)
return 0;
else
return 1;
}
As commonsware mentioned in his answer this way Android will maintain different object pools for different list items, which also means you can remove the check for listRow_previous in my example and change the if (convertView == null || (listRow != listRow_previous)) to if (convertView == null) only.