title: Need some explanations about Android fragments and ActionBar tabs
body: <p>I am trying to understand Android fragments and navigation, but there is something I just don't know how to do. I have created an app, with a MainActivity containing a viewPager :</p>
  
  <pre><code>public class MainActivity extends FragmentActivity implements TabListener
  {
      private ViewPager viewPager;
      private TabsPagerAdapter mAdapter;
      private ActionBar actionBar;
      private String[] tabNames = {"Tab 1", "Tab 2", "Tab 3"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          viewPager = (ViewPager) findViewById(R.id.pager);
          actionBar = getActionBar();
          mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
  
          viewPager.setAdapter(mAdapter);
          actionBar.setHomeButtonEnabled(false);
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          for(int i = 0 ; i &lt; tabNames.length ; i++) 
              actionBar.addTab(actionBar.newTab().setText(tabNames[i]).setTabListener(this));
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {}
  
      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft)
      {
          viewPager.setCurrentItem(tab.getPosition());
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {}
  }
  </code></pre>
  
  <p>Here is <code>TabsPagerAdapter</code> :</p>
  
  <pre><code>public class TabsPagerAdapter extends FragmentPagerAdapter
  {
      public TabsPagerAdapter(FragmentManager fm)
      {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int index)
      {
          if(index == 0) return new FirstFragment();
          else if(index == 1) return new SecondFragment();
          else return new ThirdFragment();
      }
  
      @Override
      public int getCount()
      {
          return 3;
      }
  }
  </code></pre>
  
  <p>And my <code>FirstFragment</code> is a list so it extends <code>ListFragment</code>. Here is what it looks like :</p>
  
  <p><img src="https://i.stack.imgur.com/bDZ5l.png" alt="enter image description here"></p>
  
  <p>Now I want to go to another view if I click an item. Before I used to do it like this in apps without action bar and tabs :</p>
  
  <pre><code>Intent i = new Intent(this.getActivity().getApplicationContext(), MyNewActivity.class);
  startActivity(i);
  </code></pre>
  
  <p>But now when I do this it doesn't display the action bar on top of the screen anymore, and I also want to keep the navigation state on this tab, if I go to another tab and then come back. What should I do?</p>
  
  <p>Thanks for your help. </p>