The item view type you are returning from
getItemViewType()
is >= getViewTypeCount()
.
The accepted answer is correct. This is what I am doing to avoid the problem:
public enum FoodRowType {
ONLY_ELEM,
FIRST_ELEM,
MID_ELEM,
LAST_ELEM
}
@Override
public int getViewTypeCount() {
return FoodRowType.values().length;
}
@Override
public int getItemViewType(int position) {
return rows.get(position).getViewType(); //returns one of the above types
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With