I want to detect a doubletap on a view, like for example a button, and then know which view it was. I have seen this similar question but the question they say it is a duplicate of it does not seem to answer my question.
All I can find is to add a GestureDetector to the activity, and add a OnDoubleTapListener to it. But that is only triggered if I tap on the background/layout of my screen. It is not triggered when I (double)tap a button.
This is the code I have inside my onCreate:
gd = new GestureDetector(this, this); gd.setOnDoubleTapListener(new OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent e) { Log.d("OnDoubleTapListener", "onDoubleTap"); return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { Log.d("OnDoubleTapListener", "onDoubleTapEvent"); //if the second tap hadn't been released and it's being moved if(e.getAction() == MotionEvent.ACTION_MOVE) { } else if(e.getAction() == MotionEvent.ACTION_UP)//user released the screen { } return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { Log.d("OnDoubleTapListener", "onSingleTapConfirmed"); return false; } });