siva
siva

Reputation: 167

How to cancel An Event in android

I have written code for an application. It has some motion events. The motion event has got Down, Move and Up states. The event is bounded to a specific key until Up/Cancel happens.

But I want to cancel the motion event when Move happens, but not the entire application. How can I cancel the motion event?

Please give me some idea. Any helpful links/sample code is appreciated.

Upvotes: 4

Views: 2087

Answers (1)

Vikash Kumar
Vikash Kumar

Reputation: 631

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;
         }

Whatever Event you want to disable just don,t put any code in that case. and at the end return the true value.

Upvotes: 1

Related Questions