Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 864
siva Avatar asked Jan 23 '26 03:01

siva


1 Answers

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.

like image 101
Vikash Kumar Avatar answered Jan 25 '26 16:01

Vikash Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!