Ordering in ListView destroyed after scrolling

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Ordering in ListView destroyed after scrolling

Postby TheChosen » Sun Jul 19, 2009 8:46 pm

I created a ListActivity that shows custom views. Each of them shows an icon alongside a title text and a description. This custom view is delegated using a ListAdapter (which extends BaseAdapter). After adding some elements I have two problems:

    I add ordered elements from 1 to 14 but the ones that are shown differ. It shows item 1 to 8 and then it starts again with the first one.
    After scrolling up and down the list, the items get shuffled. Is there a way to prevent the reordering of the elements?

I attached two screen shots that show the problem. Any help would be greatly appreciated.
Attachments
listview_after_scroll.png
...but after scrolling, the items get shuffled!
listview_after_scroll.png (141.31 KiB) Viewed 128 times
listview_okay.png
at first, the ordering seems okay...
listview_okay.png (142.98 KiB) Viewed 128 times
TheChosen
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 06, 2009 7:18 pm
Location: Germany

Top

Postby TheChosen » Tue Jul 21, 2009 3:05 pm

I got the problem solved. The problem was in the custom adapter class's onView-method. When casting the convertView to my view object, I forgot to set the texts and image anew. This has to be done every time due to the adapter's cache. Objects from this cache are being reused so their values have to be reset every time.
TheChosen
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 06, 2009 7:18 pm
Location: Germany

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests