Created
January 4, 2016 08:36
-
-
Save Limuyang1013/e93ccada6eac4c317666 to your computer and use it in GitHub Desktop.
保存恢复ListView当前位置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void saveCurrentPosition() { | |
if (mListView != null) { | |
int position = mListView.getFirstVisiblePosition(); | |
View v = mListView.getChildAt(0); | |
int top = (v == null) ? 0 : v.getTop(); | |
//保存position和top | |
} | |
} | |
private void restorePosition() { | |
if (mFolder != null && mListView != null) { | |
int position = 0;//取出保存的数据 | |
int top = 0;//取出保存的数据 | |
mListView.setSelectionFromTop(position, top); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment