title: ViewFlipper doesn't receive touch events
body: <p>I am working on an Android project in which I use a <code>ViewFlipper</code> for flipping childs. For this I used a customized flipper. In this I override the <code>onTouchEvent()</code> method.
  The flipper contain images in each child but when I try to flip it doesn't receive any touch event. When I override the <code>ViewGroup</code> method <code>onInterceptTouchEvent()</code> and return <code>true</code>, then flipping is done but due to this my <code>onClickEvent()</code> on each image is not received.</p>
  
  <p>I am not getting where the problem is. When I return <code>false</code> from <code>onInterceptTouchEvent()</code> then the click event is being received but not the touch event.</p>
  
  <p>What am I missing?</p>
  
  <p>Code for the ViewFlipper:</p>
  
  <pre><code>public class MyViewFlipper extends ViewFlipper {
  
      static final String logTag = "ViewFlipper";
      static final int MIN_DISTANCE = 30;
      private float downX, downY, upX, upY;
      Animation slideLeftIn;
      Animation slideLeftOut;
      Animation slideRightIn;
      Animation slideRightOut;
      Context context;
      ViewFlipper viewFlipper;
  
      public MyViewFlipper(Context context) {
          super(context);
          viewFlipper=this;
          this.context=context;
          System.out.println("I am in MyFlipper() counstructor...");
      }
  
      public MyViewFlipper(Context context, AttributeSet attrs) {
          super(context, attrs);
          this.context=context;
          viewFlipper=this;
          System.out.println("I am in MyFlipper() counstructor...");
          slideLeftIn =
              AnimationUtils.loadAnimation(context, R.anim.slide_left_in);
          slideLeftOut =
              AnimationUtils.loadAnimation(context, R.anim.slide_left_out);
          slideRightIn =
              AnimationUtils.loadAnimation(context, R.anim.slide_right_in);
          slideRightOut =
              AnimationUtils.loadAnimation(context, R.anim.slide_right_out);
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN: {
                  downX = event.getX();
                  downY = event.getY();
                  return true;
              }
              case MotionEvent.ACTION_UP: {
                  upX = event.getX();
                  upY = event.getY();
  
                  float deltaX = downX - upX;
                  float deltaY = downY - upY;
  
                  // swipe horizontal?
                  if (Math.abs(deltaX) &gt; MIN_DISTANCE) {
                      // left or right
                      if (deltaX &lt; 0) {
                          this.onLeftToRightSwipe();
                          return true;
                      }
                      if (deltaX &gt; 0) {
                          this.onRightToLeftSwipe();
                          return true;
                      }
                  } else {
                      if(Math.abs(deltaX)&lt;15){
                          onClickEvent();
                      }
                      //Log.i(logTag, "Swipe was only " + Math.abs(deltaX)
                      //+ " long, need at least " + MIN_DISTANCE);
                  }
                  // swipe vertical?
                  if (Math.abs(deltaY) &gt; MIN_DISTANCE) {
                      // top or down
                      if (deltaY &lt; 0) {
                          this.onTopToBottomSwipe();
                          return true;
                      }
                      if (deltaY &gt; 0) {
                          this.onBottomToTopSwipe();
                          return true;
                      }
                  } else {
                      Log.i(logTag, "Swipe was only " + Math.abs(deltaX)
                          + " long, need at least " + MIN_DISTANCE);
                  }
  
                  return true;
              }
          }
          return false;
  
      }
  
      public void onRightToLeftSwipe() {
  
          viewFlipper.setInAnimation(slideLeftIn);
          viewFlipper.setOutAnimation(slideLeftOut);
          viewFlipper.showNext();
      }
  
      public void onLeftToRightSwipe() {
  
          viewFlipper.setInAnimation(slideRightIn);
          viewFlipper.setOutAnimation(slideRightOut); 
          viewFlipper.showPrevious();
      }
  
      public void onTopToBottomSwipe() {
          Log.i(logTag, "onTopToBottomSwipe!");
          // activity.doSomething();
      }
  
      public void onBottomToTopSwipe() {
          Log.i(logTag, "onBottomToTopSwipe!");
          // activity.doSomething();
      }
  
      public void onClickEvent(){
          Toast.makeText(context, "Click",Toast.LENGTH_SHORT);
      }
  
      @Override
      public boolean onInterceptTouchEvent(MotionEvent ev) {
          return true;    // Here if true then Flipping done.
                          // And if false then click event done. 
      }
  
  }
  </code></pre>