title: Android- Gesture enabled tab layout with lists
body: <p>I am trying to get swipe gestures working with a tab layout in an android app. What I am working with is a single activity with a different view for each tab. Rather than having them contained in a FrameLayout, I am using a ViewFlipper for my tab content. I want to make left/right swipe gestures change the active tabs the active tab to the one to the left or right of the current one. </p>
  
  <p>The problem arises when swiping to and from my third list after items have been added to it. I'm seeing a behavior where the third list is displayed, but is overlaid on the list I was on previously. </p>
  
  <p>Any ideas why this is happening?</p>
  
  <p>My java code for switching views/tabs:</p>
  
  <pre><code>public void onSwipe(int direction) {     
      switch (direction) {     
          case SimpleGestureFilter.SWIPE_RIGHT : swipeRight(); break;
          case SimpleGestureFilter.SWIPE_LEFT :  swipeLeft(); break;
      }    
  }
  
  private void swipeLeft() {  
  
      viewFlipper.setInAnimation(this,R.anim.slide_in_right);
      viewFlipper.setOutAnimation(this,R.anim.slide_out_left);
      viewFlipper.showNext();
      tabHost.setCurrentTab( (tabHost.getCurrentTab()+1 ) % NUMTABS );
  }
  
  private void swipeRight() {
  
      viewFlipper.setInAnimation(this, android.R.anim.slide_in_left); 
      viewFlipper.setOutAnimation(this,android.R.anim.slide_out_right);
      viewFlipper.showPrevious();
      tabHost.setCurrentTab( (tabHost.getCurrentTab()+(NUMTABS-1) ) % NUMTABS ); //loop around to avoid -1
  }
  </code></pre>
  
  <p>My layout:</p>
  
  <pre><code>&lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
  &lt;RelativeLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="5dp"&gt;
      &lt;TabWidget
          android:id="@android:id/tabs"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true" /&gt;
      &lt;ViewFlipper
          android:id="@android:id/tabcontent"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@android:id/tabs"
          android:layout_above="@+id/search_button"
          android:padding="5dp" &gt;          
           &lt;ListView android:id="@+id/list1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:choiceMode="multipleChoice"
            android:layout_alignParentTop="true"
            android:textFilterEnabled="true"/&gt;
  
           &lt;ListView android:id="@+id/list2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:choiceMode="multipleChoice"
            android:layout_alignParentTop="true"
            android:textFilterEnabled="true"/&gt;
  
  
           &lt;ListView android:id="@+id/list3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_alignParentTop="true"/&gt;
  
  
       &lt;/ViewFlipper&gt;
       &lt;Button android:id="@+id/search_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:text="Search" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>