ListView - Index and Position Behavior upon restart()
Posted
by tunneling
on Stack Overflow
See other posts from Stack Overflow
or by tunneling
Published on 2010-05-19T01:03:21Z
Indexed on
2010/05/19
1:10 UTC
Read the original article
Hit count: 226
I am using a ListView with an ArrayAdapter that holds objects. When I select an item, I am capturing the position and index of the selected item. If I scroll down prior to selection, the position and index represent the location of the item in the list. Selecting that items takes me to another activity. When I use the back button to return to the list, it seems that the ListView get's a new position and index for the visible items.
As a result, I can't figure out how to reference the selected item during the restart() of the ListView Activity. I have tried to caputure position and index, but as I've said, they change upon returning to the Activity.
Is my understanding of the ListView "redraw" correct? Does it renumber my items based on what's visible? -When in the life cycle is getView() called? Is there a way to force an update to the ListView so that my caputured index still points to the same object?
Thanks, Jason
© Stack Overflow or respective owner