I am in the process of developing a lengthy list view that is created from a JSON array coming from my server. When an item is selected it could be anywhere in the list and when I return I want to jump back to that specific item.
I was thinking about the setSelection(position) structure but I was curious as to how the position variable is set. Does it need to come from the JSON string or is it a variable that is created while the list view is being filled. If it is created what is the syntax of retrieving it so I can pass it to the Activity in charge of displaying more data and then back to the original Activity when the list view is redisplayed.
As additional information I just added the functionality of storing it in my preferences so it will load faster so it is stored on the phone. If the data has changed due to user interaction I retrieve the new JSON string so maintaining position is not critical.
I was hoping to not need to rebuild my JSON string to contain this variable.
Thanks
use
setOnItemClickListeneron ListView and save the current position on a local variable (persist or non persist depends on need ) , use thissetSelectionmethod onListViewobject while you come back (onResumeif its a Activity) , check for nulls before setting.