【问题标题】:disable listview scrolling when ontouchlistener is fired触发 ontouchlistener 时禁用列表视图滚动
【发布时间】:2014-03-25 03:32:10
【问题描述】:

我在我的列表视图上附加了一个 ontouch 监听器,因此我可以从左到右拖动列表视图。在我拖动列表视图时,我也可以滚动它。如何在拖动时禁用列表视图滚动。

【问题讨论】:

    标签: android android-listview ontouchlistener


    【解决方案1】:
    listView.setOnTouchListener(new OnTouchListener() {
    
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_MOVE) {
                return true; // Indicates that this has been handled by you and will not be forwarded further.
            }
            return false;
        }
    });
    

    listView.setScrollContainer(false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-03
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 2013-12-30
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多