[Android] Maintain ListView Position when Refreshing

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

// save index and top position
int index = mList.getFirstVisiblePosition();
View v = mList.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();

// ...

// restore
mList.setSelectionFromTop(index, top);

沒有留言 :

張貼留言