保存恢復ListView當前位置

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);
    }
}

所屬標簽

無標簽

25选5玩法中奖