I have a ListView which shows items from ArrayAdapter. I want to animate the view when it is cliked. The problem is that on different versions of android I am getting differ
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 :)