androidlistviewlistview-adapter

bad convertView type BaseAdapter of ListView


I have a list view adapter that uses different types of view rows.

Most of the time it works fine. But when I remove an element from the list it crashes. It sends a convertView of the incorrect type to getView

public View getView(int position, View convertView, ViewGroup patent) ...  

But getItemViewType is returning the correct type.

public int getItemViewType(int position)

so I see something that looks like this

give me the type for position 1 -> returns correct type (say 1)

give me a view for position 1 with a content view for the wrong type (say type 2.)

Any ideas?


Solution

  • That's normal, if you get a View with different type in convertView, you would create a new View, and not reuse convertView.

    Probably there are no reusable views with the given type.

    Note: This answer is from 2011 and might no longer apply.