I hope someone can share some light on a issue I have with using the
convertView that is supplied by the BaseAdapter.

The problem is that I have a couple of different listviews in my app. When
using the convertView with listviews that only shows one type everything
works fine, and I experience a big performance increase. Nice!

However I also have a listview that can show 4 different types of views, and
I see that getView is supplied with a convertView that is of the wrong type.
In my BaseAdapter implementation I have added the following:

@Override
public int getItemViewType(int position){
           LiveStreamElement elem = liveStreamElements.get(position);
           switch(elem.getElementType()){
                      case TYPE_A:
                                 return 0;
                      case TYPE_B:
                                 return 1;
                      case TYPE_C:
                                 return 2;
                      case TYPE_D:
                                 return 3;
                      default:
                                 return -1;
           }
}

@Override
public int getViewTypeCount(){
           return 4;
}

>From the log I can see that the correct types are returned in
getItemViewType, but nevertheless the convertView that is supplied in the
getView method is not guaranteed to be of the right type.
Ex if I add elements to the list and call notifyDataSetChanged on the list,
sometimes the views in the list will switch positions. The strange thing is
that for the most part it seems to work when I scroll, but if I reload the
list, some elements might have changed places. If I change the layout of the
screen, ex adds a view beneath the listview, which then forces the listview
to be redrawn, its elements will ‘sometimes’ exchange places too.
I really hope somebody can share some light on this issue…this thing should
be rather simple, but it is driving me nuts :D

Any input is much very appreciated :)

Klaser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to