/** scrollState有三种状态,分别是SCROLL_STATE_IDLE、SCROLL_STATE_TOUCH_SCROLL、SCROLL_STATE_FLING
SCROLL_STATE_IDLE是当屏幕停止滚动时
SCROLL_STATE_TOUCH_SCROLL是当用户在以触屏方式滚动屏幕并且手指仍然还在屏幕上时
SCROLL_STATE_FLING是当用户由于之前划动屏幕并抬起手指,屏产生惯性滑动时*/
private boolean scrollFlag = false;// 标记是否滑动 private int lastVisibleItemPosition;// 标记上次滑动位置
listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case SCROLL_STATE_TOUCH_SCROLL: scrollFlag = true; break; case SCROLL_STATE_FLING: scrollFlag = false; break; case SCROLL_STATE_IDLE: scrollFlag = false; break; default: break; } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (scrollFlag) { if (firstVisibleItem > lastVisibleItemPosition) {//上滑 } if (firstVisibleItem < lastVisibleItemPosition) {//下滑 } if (firstVisibleItem == lastVisibleItemPosition) { return; } lastVisibleItemPosition = firstVisibleItem; } } });