OnGestureListener onDown方法不会被调用 [英] OnGestureListener onDown method never gets called

查看:835
本文介绍了OnGestureListener onDown方法不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 onScroll onTouchEvent 获取调用,而不是 onDown 方法。事实上,当我登录了 distaceX onDown 我得到的其中几个注销,第一永远是相对的到我结束最后一个滚动的地方。

My onScroll and areonTouchEvent getting called, but not the onDown method. In fact, when I log the distaceX in onDown I get several of them logged out, and the first is always relative to the spot where I ended the last scroll.

 @Override 
 public boolean onTouchEvent(MotionEvent me){ 
   this.detector.onTouchEvent(me);

  return super.onTouchEvent(me); 
 }

 @Override
 public boolean onDown(MotionEvent e) {
       Log.d("---onDown---",".");
   return false;

 }

 @Override
 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
   float distanceY) {
  Log.d("---onScroll---", "" + distanceX);
  return false;
 }

任何想法,为什么 onDown 就不叫?

编辑:

我改变了我的 onTouchEvent 以下块,只有ACTION_MOVE被记录下来。

I changed my onTouchEvent to the following block, and only the ACTION_MOVE gets logged.

 float gestureDistance = 0;
 @Override 
 public boolean onTouchEvent(MotionEvent me){ 
     switch (me.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:               
            Log.d("actionDown", "gestureDistance:" + gestureDistance);
            break;
        case MotionEvent.ACTION_UP:
            Log.d("actionUp", "gestureDistance:" + gestureDistance);
            break;
        case MotionEvent.ACTION_MOVE:
            Log.d("actionMove", "gestureDistance:" + gestureDistance);
            break;
        default:
            Log.d("action default", "default");
            break;
    }   

编辑:
我认为问题是,我的看法是一个web视图。我可以从偷我的事件保持的WebView?

I think the problem is that my view is a WebView. Can I keep the webview from stealing my events?

推荐答案

添加此我的onCreate 解决了这一问题。

Adding this to my onCreate fixed the problem.

    webView.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
           detector.onTouchEvent(event);
            return true;
        }
    });

这篇关于OnGestureListener onDown方法不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆