title: How to listen to doubletap on a view in android?
body: <p>I want to detect a <code>doubletap</code> on a view, like for example a <code>button</code>, and then know which view it was. I have seen <a href="https://stackoverflow.com/questions/2640119/how-to-detect-doubletap-on-a-view">this similar question</a> but the question they say it is a duplicate of it does not seem to answer my question.</p>
  
  <p>All I can <a href="http://www.41post.com/4194/programming/android-detecting-double-tap-events" rel="noreferrer">find</a> is to add a <code>GestureDetector</code> to the activity, and add a <code>OnDoubleTapListener</code> to it. But that is only triggered if I tap on the background/layout of my screen. It is <em>not</em> triggered when I (double)tap a <code>button</code>.</p>
  
  <p>This is the code I have inside my <code>onCreate</code>:</p>
  
  <pre><code>    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;  
          }  
      });  
  </code></pre>