如何在android中取消一个事件

时间:2012-02-27 11:16:48

标签: android event-handling

我已为应用程序编写代码。它有一些运动事件。 运动事件有Down,Move和Up状态。 在Up / Cancel发生之前,事件被绑定到特定键。

但我希望在Move发生时取消运动事件,但不是整个应用程序。 如何取消动议事件?

请给我一些想法。任何有用的链接/示例代码表示赞赏。

1 个答案:

答案 0 :(得分:1)

public boolean onTouch(View v, MotionEvent event) {

    switch (v.getId()) {
    case R.id.camera_surface:
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
          case MotionEvent.ACTION_DOWN:

            break;
          case MotionEvent.ACTION_POINTER_DOWN:

          case MotionEvent.ACTION_UP:

          case MotionEvent.ACTION_POINTER_UP:

          case MotionEvent.ACTION_MOVE:
                   }
                  }
                return true;
         }

无论你想要禁用哪个事件,都要在这种情况下输入任何代码。并最终返回真正的价值。