title: Programmatically switch tabs in Android using ActionBarSherlock
body: <p>I couldn't find any info about this but, how can i programmatically switch tabs in ActionBarSherlock?</p>
  
  <p>Normally when i want to switch views i'd use something like:</p>
  
  <pre><code>Intent intentSecondView = new Intent(this, SecondView.class);
  this.startActivity(intentSecondView);
  </code></pre>
  
  <p>But obviously this doesn't work, because the views in the tabs are fragments.</p>
  
  <p>So is there a way to switch between tabs by code when using ActionBarSherlock??</p>
  
  <hr>
  
  <p>This is how i add an actionbar with tabs currently.</p>
  
  <p>In my onCreate method i have:</p>
  
  <pre><code>    mViewPager = new ViewPager(this);
      mViewPager.setId(R.id.pager);
  
      setContentView(mViewPager);
      ActionBar bar = getSupportActionBar();
      bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
      mTabsAdapter = new TabsAdapter(this, mViewPager);
  
      mTabsAdapter.addTab(
              bar.newTab().setText("Fragment 1"),
              MyFragment1.class, null);
      mTabsAdapter.addTab(
              bar.newTab().setText("Fragment 2"),
              MyFragment2.class, null);
  </code></pre>
  
  <p>I added nothing in my AndroidManifest file to create the tabs. It's all programmatically.</p>