AbsListView OnScrollListener

1、判断listView状态
AbsListView.OnScrollListener onScrollListener = new AbsListView.OnScrollListener() {// ListView
// 触摸事件

public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
}

public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) {
case AbsListView.OnScrollListener.SCROLL_STATE_FLING:// 滑动状态
threadFlag = false;
break;
case AbsListView.OnScrollListener.SCROLL_STATE_IDLE:// 停止
threadFlag = true;
startThread();
break;
case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:// 触摸listView
threadFlag = false;
break;
default:
// Toast.makeText(contextt, "default",
// Toast.LENGTH_SHORT).show();
break;
}
}
};
2、获取当前屏幕上显示的items:
mListView.getFirstVisiblePosition();
mListView.getLastVisiblePosition();


你可能感兴趣的:(AbsListView OnScrollListener)