ListView:限制滚动速度

时间:2012-07-12 08:10:35

标签: android android-listview swipe-gesture

  

可能重复:
  Android Listview slow down scroll speed

当用户在ListView上滑动时,其滚动速度可能会非常高。我想限制速度 - 有可能吗?

1 个答案:

答案 0 :(得分:0)

检查出来 - :

private class SpeedMeterOnScrollListener implements OnScrollListener {

        private long timeStamp;
        private int lastFirstVisibleItem;

        public SpeedMeterOnScrollListener() {
            timeStamp = System.currentTimeMillis();
            lastFirstVisibleItem = 0;
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            long lastTime = System.currentTimeMillis();
            //calculate speed by firstVisibleItem, lastFirstVisibleItem, timeStamp and lastTime
            timeStamp = lastTime;
            lastFirstVisibleItem = firstVisibleItem;
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    }