Android: Disable touch after double tap or long press

I have created a GestureDetector to detect a double tap or long press. If either of them are triggered, I would like to disable any more touches. How can I do this?

Thanks!

Answers


Well there could be two ways to do this. 1. you have to implement onTouchListener along with a conditional variable say boolean. declare

Boolean isDouble = false; // your activity level variable

now when you have detected the double touch or longpress set it to true

isDouble = true;

now in your onTouchListener .

        view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if(isDouble)
                return false;

            }
        });
  1. Other method may not work properly on some devices but it can work for your case.

    view.setOnTouchListener(null);


Need Your Help

Is there a way to implement algebraic types in Java?

java class abstract-class final adts

Is it possible, in Java, to enforce that a class have a specific set of subclasses and no others? For example: