ArrayIndexOutOfBoundsException with custom Android Adapter for multiple views in ListView
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}@Overridepublic int getViewTypeCount() { return FoodRowType.values().length;}@Overridepublic int getItemViewType(int position) { return rows.get(position).getViewType(); //returns one of the above types}