How to disable GestureListener in android?

I have implemented a GestureListener and it works fine, but how can I remove the GestureListener from my view?

@Override
public boolean onTouchEvent(MotionEvent event) {
    if ( event.getAction() == MotionEvent.ACTION_UP ) {
        //   remove gestureDetector
    } else {
        mGestureDetector.onTouchEvent(event);
    }
    return true;
}

Regards, Nishant Shah

+3
source share
1 answer

I'm not sure what you mean by "remove gestureDetector".

Instead, you should first transfer the MotionEvent to the GestureDetector and handle the event yourself, only if the GestureDetector does not:

public boolean onTouchEvent(MotionEvent event) {
    if (mGestureDetector.onTouchEvent(event)) {
        return true;
    }

    <your code to process the event here>
}
+1
source

Source: https://habr.com/ru/post/1757341/


All Articles