That's not how you should be managing the layout change of the items. You should use the getItemViewType()
and getViewTypeCount
methods:
public static final int SINGLE = 0;
public static final int MULTIPLE = 1;
@Override
public int getItemViewType(int position) {
return isListSingleColumn ? SINGLE : MULTIPLE; // call notifyDataSetChanged when you modify isListSingleColumn
}
@Override
public int getViewTypeCount() {
return 2;
}
// in the newView() method:
final int position = cursor.getPosition();
final int type = getItemViewType(position);
View itemView
if (type == SINGLE) {
itemView = mInflater.inflate(R.layout.explorer_row_single_column, viewGroup, false);
} else {
itemView = mInflater.inflate(R.layout.explorer_row_multi_column, viewGroup, false);
}
// rest of the code
Also, as its name implies, the bindView()
method is to be used to bind data to the row view that you receive, I don't see why did you built the item's row again there.