title: OnClick ImageView with OnFling ViewFlipper
body: <p>I have a ViewFlipper which holds a single ImageView. i want to be able to swipe to change the image / view, and click the image to play a sound.</p>
  
  <p>I have a GestureDetector which is handling OnFling to change the view. I tried to put an onClickListener to the imageview, which worked but stopped the OnFling working.</p>
  
  <p>Lastly, I added an onSingleTapConfirmed to my GestureDetector. This worked, however it registers a click anywhere in the Activity not just the ImageView.</p>
  
  <p>Can anyone suggest how to narrow down the onSingleTapConfirmed to just work on the Imageview?</p>
  
  <p>Here's my code so far:</p>
  
  <pre><code> class MyGestureDetector extends SimpleOnGestureListener {
      @Override
      public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
          try {
              if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH)
                  return false;
              // right to left swipe
              if(e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                  Log.v("Swipe", "Right to Left");
  
                  viewFlipper.setInAnimation(slideLeftIn);
                  viewFlipper.setOutAnimation(slideLeftOut);
                  viewFlipper.addView(nextImage(true));
  
                  viewFlipper.showNext();
  
              }  else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                  Log.v("Swipe", "Left to Right");
  
                  viewFlipper.setInAnimation(slideRightIn);
                  viewFlipper.setOutAnimation(slideRightOut);
                  viewFlipper.addView(nextImage(false));
                  viewFlipper.showNext();
              }
          } catch (Exception e) {
              // nothing
          }
          return false;
      }
  
      @Override
      public boolean onSingleTapConfirmed(MotionEvent e)
      {
          // TODO Auto-generated method stub
  
          Log.v("SingleTap", "OnSingleTapConfirmed Run");
  
          return super.onSingleTapConfirmed(e);   
  
      }    
  
  }
  
  private View nextImage(boolean righttoleft) {
      ImageView imgv1 = new ImageView(this);
  
      if(righttoleft == true)
      {
  
              Uri image = Uri.parse("android.resource://com.owentech.brainybaby/drawable/" + variables.letters[variables.currentpos]);
              imgv1.setImageURI(image);
              imgv1.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  
      return imgv1;
  }
  </code></pre>