【问题标题】:motionEvents didn't work Android JavamotionEvents 不起作用 Android Java
【发布时间】:2014-02-18 20:06:30
【问题描述】:

我无法在 Logcat 中从以下事件中获取消息:MotionEvent.ACTION_MOVEMotionEvent.ACTION_UP。我找不到解决方案,所以我在这里问。

我的班级中有这个被覆盖的方法:

@Override
public boolean onTouchEvent(MotionEvent event){
        int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_MOVE:
                Log.d("action","Action was MOVE");
            break;
            case MotionEvent.ACTION_DOWN:
                Log.d("action","Action was DOWN");
                break;
            case MotionEvent.ACTION_UP:
                Log.d("action","Action was UP");
                break;
            default:
                break;
        }
    }
    return super.onTouchEvent(event);
}

在 LogCat 中,我只能看到来自 MotionEvent.ACTION_DOWN : "action" "Action was DOWN" 。没有来自其他操作的消息。

我在手机和 AVD 中尝试过。

感谢您的回复。

答案: return 必须设置为 true 而不是超级构造函数。

【问题讨论】:

    标签: java android motionevent


    【解决方案1】:

    只需将 return 设置为 True 而不是超级构造函数:)

    【讨论】:

      猜你喜欢
      • 2011-06-15
      • 2014-05-15
      • 2015-12-29
      • 2017-07-28
      • 2014-09-18
      • 2012-05-06
      • 1970-01-01
      • 2015-09-03
      • 1970-01-01
      相关资源
      最近更新 更多