title: Android ActionBar Tabs - Swipe
body: <p>it would be nice, if i could swipe between the tabs i had in my actionbar.</p>
  
  <p>I've followed these tutorial: <a href="http://developer.android.com/training/implementing-navigation/lateral.html" rel="nofollow">http://developer.android.com/training/implementing-navigation/lateral.html</a> but it wont work. :( I cannot swipe with a gesture between the tabs. </p>
  
  <p>Here is my main activity:</p>
  
  <pre><code>public class Hauptmenue_extended extends ActionBarActivity implements
          android.content.DialogInterface.OnClickListener {
  @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_hauptmenue_extended);
  
          try {           
              mPullToRefreshAttacher = PullToRefreshAttacher.get(this);
  
              actionBar = getSupportActionBar();
              actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);    
              actionBar.setDisplayHomeAsUpEnabled(true);
              actionBar.setHomeButtonEnabled(true);
  
              mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
  
              mViewPager = (ViewPager) findViewById(R.id.pager);
              mViewPager.setAdapter(mAdapter);
  
  
              Tab tabB = actionBar.newTab();
              tabB.setText("Home");
              tabB.setIcon(R.drawable.icon_home);
              tabB.setTabListener(new TabListener&lt;Startmenue_activity&gt;(this,
                      "Start", Startmenue_activity.class, this.mViewPager));
              actionBar.addTab(tabB);
  
              Tab tabA = actionBar.newTab();
              tabA.setText("");
              tabA.setIcon(R.drawable.icon_nachrichten_sel);
              tabA.setTabListener(new TabListener&lt;Nachrichten_activity&gt;(this,
                      "Nachrichten", Nachrichten_activity.class, this.mViewPager));
              actionBar.addTab(tabA);
  
              Tab tabC = actionBar.newTab();
              tabC.setText("");
              tabC.setIcon(R.drawable.icon_favoriten);
              tabC.setTabListener(new TabListener&lt;Favoriten_activity&gt;(this,
                      "Favoriten", Favoriten_activity.class, this.mViewPager));
              actionBar.addTab(tabC);
  
  
  
              this.conEinst = new conEinstellungen(getBaseContext());
  
          } catch (Exception ex) {
              ex.printStackTrace();
              // HelperClassAlertDialog.zeigeInfoDialog(this, "Error...",
          }
      }
  
  public class TabsPagerAdapter extends FragmentPagerAdapter {
  
          public TabsPagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          public Fragment getItem(int index) {
  
              switch (index) {
              case 0:
                  // Top Rated fragment activity
                  return new Startmenue_activity();
              case 1:
                  // Games fragment activity
                  return new Nachrichten_activity();
              case 2:
                  // Movies fragment activity
                  return new Favoriten_activity();
              }
  
              return null;
          }
  
          public int getCount() {
              // get item count - equal to number of tabs
              return 3;
          }
  
      }
  </code></pre>
  
  <p>And this is the XML:</p>
  
  <blockquote>
    <p></p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;android.support.v4.view.PagerTabStrip
          android:id="@+id/tabs"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="top" /&gt;
  &lt;/android.support.v4.view.ViewPager&gt;
  </code></pre>
    
    <p></p>
  </blockquote>