开发者

ListView recycle views that are visible on screen

I have a problem with ListView which recycles views that are visible on the screen. I can have up to 4 items in my ListView, they are all visible on screen. After I update a property of an object in the ArrayList that the ListAdapter uses i call the notifyDataSetChanged() method of the lis开发者_开发百科t adapter. This causes the ListView to recycle the views and to redraw it self. The problem is that it's doing the recycling in a reverse order. so if i have a button on the first Listview item it will be in the second list view item after the notifyDataSetChanged(). I have getView that changes the convertView properties except for the button onTouchListener.

This is very problematic if i have a button that works with touch event (Like PTT button). its visible for sometime and then it becomes invisible :-(. 1. why does the ListView recycle items that are visible on the screen ? is this normal behaviour? why does it do in reverse order ? 2. what can I do to solve my issue ?


You should provide code for getview() method. And adding button to an item could cause problems when you are not using checks on adding button. Rather than adding button you should include button in all items and just make visible invisible the button at specific position where you want. Also make check of "null" for creating convertview in getview() method. This way it would not recycle/create views/item if they are not null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜