I am attempting to create a custom Adapter for my ListView since each item in the list can have a different view (a link, toggle, or radio group), but when I try to run the
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
}