抓不住的GridView的MotionEvent.ACTION_DOWN [英] Can't catch MotionEvent.ACTION_DOWN of GridView

查看:166
本文介绍了抓不住的GridView的MotionEvent.ACTION_DOWN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下OnTouchListener

I have the following OnTouchListener

    gridview.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == MotionEvent.ACTION_DOWN) {

                start_x = event.getX();
                start_y = event.getY();
                Log.d(TAG,start_x + " " + start_y);

            }

但体内的如果永远不会执行的语句。但是,对于其他活动,如ACTION_MOVE,相应的'如果'语句的身体并得到执行。任何人都知道为什么吗?

But the body of the 'if' statement is never executed. However, for other events, like ACTION_MOVE, the body of the corresponding 'if' statement does get executed. Anyone know why?

推荐答案

这可能是向下事件正被另一个观点消耗。
尝试在活动超载onTouchEvent(MotionEvent),看看你能赶上活动。

It could be that the DOWN event is being consumed by another view. Try overloading "onTouchEvent(MotionEvent)" in your activity, and see if you are able to catch the event.

这篇关于抓不住的GridView的MotionEvent.ACTION_DOWN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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