getting View for ListView item / reverse order on 2.2; works on 4.0.3

爷,独闯天下 提交于 2019-12-01 18:45:56

OK. so this is what is happening :

On a clean ListView When I register onItemClickListener and perform clicks adapter getView method for views is not called. This is what I would expect.

If I set a mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE) this makes getView methods run right after click is registered. This is also what is expected.

However the difference between 2.2 and 4+ versions is that : on 2.2 : when this refresh happens getView operates on a reversed list of views (see my question) on 4+ (possibly API 11+) : getView operates on normal order of list

What is the most interesting part is that when I delay call to getViewForListPosition by 10ms everything works fine and adapter has proper list of views (normal order again). So it seems that the order of views is reversed only during adapter refresh with CHOICE_MODE_SINGLE

To solve this problem I dont change listview mode to CHOICE_MODE_SINGLE so that adapter doesn't fire during click. I set bg/graphics for clicked item on my own inside onItemClicked

hope that it saves someone some time :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!