Android ListView 获取滚动位置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10865150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ListView get scroll position?
提问by user291701
I'm using a MergeAdapter (from Mark Murphy's excellent series of projects). You use it with a ListView. I'm trying to rebuild the contents of the adapter on a refresh (instead of refreshing "in place" and calling notifyDataSetChange()).
我正在使用 MergeAdapter(来自 Mark Murphy 的优秀项目系列)。您将它与 ListView 一起使用。我正在尝试在刷新时重建适配器的内容(而不是“就地”刷新并调用 notifyDataSetChange())。
I'd like to get the y-scroll value of the listview so I can reset to that after I rebuild my list. This doesn't seem to be possible?
我想获取列表视图的 y 滚动值,以便在重建列表后可以重置为该值。这似乎不可能?
Thanks
谢谢
采纳答案by Tarun
Implement OnScrollListener for your listview.
为您的列表视图实现 OnScrollListener。
@Override
public void onScroll(AbsListView absListView, int firstVisible, int visibleCount, int totalCount) {
//firstvisible is your first visible item in the list
}