开发者

Android listadapter Anchor

开发者 https://www.devze.com 2023-01-02 14:58 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消