开发者

How to retain Android ListView scroll position when returning to an activity? [duplicate]

This question already has answers here: Closed 10 years ago. 开发者_JAVA百科

Possible Duplicate:

Maintain/Save/Restore scroll position when returning to a ListView

The user views a listview of items, they move to an activity that shows detail for one item, and then hit Back and return to the list activity but I want the list to reflect its prior scroll position.

Should I store the scroll position as a member variable on the activity in onPause or is there a better way?


Save the position in an instance variable on onPause and in onResume check if there is position value and move to it.

e.g. using

private int currentPostion;

and then in onResume do..

getListView().setSelection(currentPosition);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜