title: Android: GestureDetector not working (gestureDetector.onTouchEvent(event) always false) with Tabs (TabActivity, Tabwidget)
body: <p>I have implemented my TabActivity with different child activities:</p>
  
  <pre><code>intent = new Intent().setClass(this, MyChildTabActiviy.class);
  // Initialize a TabSpec for each tab and add it to the TabHost
  spec = getTabHost.newTabSpec("tag").setIndicator("indicator", getResources().getDrawable(R.drawable.icon)).setContent(intent);
  getTabHost.addTab(spec);
  ...
  </code></pre>
  
  <p>So far no problems, everything works perfectly fine. I'm switching programmatically between tabs, replacing activities within tabs with ActivityGroups, etc. just as it's shown in many tutorials.</p>
  
  <p>But my problem is, that when I want to check for a fling gesture my gestureDetector.onTouchEvent(event) is always returning false, thus no gesture is registrated.</p>
  
  <p>This is my implementation of gestureDetector:</p>
  
  <pre><code>public class MyChildTabActiviy extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          // ... building views, controls, etc.
          GestureDetector gestureDetector = new GestureDetector(this, new MyGestureDetector());
      }
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          return gestureDetector.onTouchEvent(event);
      }
   class MyGestureDetector extends SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
     if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH)
      return false;
     // left to right swipe and right to left swipe
     if (e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE
       &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
      //... fling logic ...
      return true;
     } else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE
       &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
      //... fling logic ...
      return true;
     }
     return false;
    }
   }
  </code></pre>
  
  <p>The thing is, that this code (and also the fling detection) works perfectly fine, when I'm starting these activities (there are four basic activities, that I sometimes switch to other activities) outside of a TabActivity, e.g. as a Launcher Activity. But I can't get it to work within a TabActivity. I already tried to append the GestureDetector to the TabActivity, but it doesn't work. I tried to append the GestureDetector to specific views like some layout views or buttons, ViewFlippers, etc. but it just doesn't work.
  When I'm debugging, I can see that the touch event is triggered and a motion is registered, but it just isn't evaluated as a fling or any other gesture.</p>
  
  <p>So my question is, are there are any limitations regarding the usage of GestureDetectors with Tabs in Android? As I said, the gestures are registrated perfectly outside a TabActivity.</p>
  
  <p>I would greatly appreciate the help of someone who knows the answer.
  If there is a limitation, how could someone get a workaround for that problem?</p>
  
  <p>Thanks in advance for answers.</p>