Lets say I have 1 - 1,000 in a list and I click on 250. When I push the back button I want to go back to 2开发者_如何学编程50 not all the way back up to 1.
Is this possible?
I have not tried this but you could try to save the state of the ListActivity
before advancing to the next activity. In your list item selection handler you would store the selected index in a Bundle
with saveInstanceState()
and then advance to the next activity. When the activity is returned to ( user presses back button ) you can override onRestoreInstanceState()
which will have the cached Bundle
passed to it as a parameter. From there you could call smoothScrollToPosition()
on the ListView
, passing in the saved index.
精彩评论