开发者

How to disable GestureListener in android?

开发者 https://www.devze.com 2023-01-09 08:19 出处:网络
I have implemented GestureListener, and it is working perfectly, but how can I remove GestureListener from my view?

I have implemented GestureListener, and it is working perfectly, but how can I remove GestureListener from my view?

@Override
public boolean onTouchEvent(开发者_StackOverflow中文版MotionEvent event) {
    if ( event.getAction() == MotionEvent.ACTION_UP ) {
        //   remove gestureDetector
    } else {
        mGestureDetector.onTouchEvent(event);
    }
    return true;
}

Regards, Nishant Shah


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

Instead, you should consider passing the MotionEvent to the GestureDetector first, and processing the event yourself only if the GestureDetector does not, with something like this:

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

    <your code to process the event here>
}
0

精彩评论

暂无评论...
验证码 换一张
取 消