title: How to show selected fragment in action bar tab
body: <p>I am facing one issue regarding tab swipe. My project is built on Android 3.2. I am implementing tab swipe using support library 4.0 (android-support-v4.jar). Everything implemented is working fine but when I deploy my app to an ICS device, then in portrait mode I am getting a spinner in action bar for tab selection. In portrait mode, the tab selection is not changing when swipe is done although content is changing, and everything is working fine in landscape mode.</p>
  
  <pre><code>final ActionBar actionBar = getActionBar();
  actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  actionBar.setDisplayHomeAsUpEnabled(true);
  // Set up the ViewPager with the sections adapter.
  ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
  
  mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
  
      @Override
      public void onPageSelected(int position) {
          actionBar.setSelectedNavigationItem(position);
      }
  
  });
  </code></pre>
  
  <p>I have tried putting breakpoint <code>actionBar.setSelectedNavigationItem(position);</code> on this line and even on portrait mode it's getting called but the selection is not changing.</p>
  
  <p>Can anybody help with this?</p>
  
  <p><strong>EDITED:</strong>
  Found a <a href="https://stackoverflow.com/questions/11030744/actionbar-selecttab-doesnt-refresh-spinner-in-compact-mode">similar problem</a> but don't see exactly how it is solved and how to integrate it in my code.</p>