ListView 记住位置 非Itme位置

    xiaoxiao2021-11-09  66

    应用开发中为了做到更好的用户体验,需要ListView记住上次滑动到的位置,使用getScrollY()方法总是返回0,因为getScrollY() 是View的方法。

    最后在谷歌上找到了这个:

    // 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);
    转载请注明原文地址: https://ju.6miu.com/read-678149.html

    最新回复(0)