title: Android ActionBar Tabs behavior on orientation change
body: <p>I'm developing an Android project with ActionBar Tabs.
  Tabs are viewed as tabs in portrait mode, and as a drop-down in landscape, as described here <a href="https://code.google.com/p/android/issues/detail?id=24439" rel="nofollow">https://code.google.com/p/android/issues/detail?id=24439</a></p>
  
  <p>My goal is to show images as tab headers while in portrait mode, and text title for drop-down while in landscape.
  The idea is to use a custom layout, showing only the required widget.</p>
  
  <p>Here's my code</p>
  
  <pre><code>    public class ResultListActivity extends Activity {
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              final ActionBar actionBar = getActionBar();     
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          actionBar.addTab(actionBar
                  .newTab()
                  .setCustomView(
                          getTabHeaderView(R.string.tab_recommended,
                                  R.drawable.ic_action_good))
                  .setTabListener(
                          new TabListener&lt;RecommendedFragment&gt;(
                                  RecommendedFragment.class)));
          actionBar.addTab(actionBar
                  .newTab()
                  .setCustomView(
                          getTabHeaderView(R.string.tab_favorites,
                                  R.drawable.ic_action_important))
                  .setTabListener(
                          new TabListener&lt;FavoritesFragment&gt;(
                                  FavoritesFragment.class)));
          actionBar
                  .addTab(actionBar
                          .newTab()
                          .setCustomView(
                                  getTabHeaderView(R.string.tab_nearest,
                                          R.drawable.ic_action_place))
                          .setTabListener(
                                  new TabListener&lt;NearestFragment&gt;(
                                          NearestFragment.class)));
  
          actionBar.addTab(actionBar
                  .newTab()
                  .setCustomView(
                                  getTabHeaderView(R.string.tab_cheapest,
                                          R.drawable.ic_action_dollar_sign))
                  .setTabListener(
                          new TabListener&lt;CheapestFragment&gt;(
                                  CheapestFragment.class)));
      }    
  
      private View getTabHeaderView(final int text, final int drawable) {
          View v = getLayoutInflater().inflate(R.layout.tab_header, null);
          ((ImageView) (v.findViewById(R.id.tabIcon))).setImageResource(drawable);
          ((TextView) (v.findViewById(R.id.tabText))).setText(text);
          return v;
      }
  
      private class TabListener&lt;T extends Fragment&gt; implements
              ActionBar.TabListener {
      ....
      }
  }
  </code></pre>
  
  <p>I've created two XMLs, describing <code>R.layout.tab_header</code>, in folders <code>layout-port</code> and <code>layout-land</code>, with following content</p>
  
  <p>layout-land\tab_header.xml (<code>ImageView</code> is gone)</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal" &gt;
  
      &lt;ImageView
          android:id="@+id/tabIcon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:padding="2dp"
          android:visibility="gone" /&gt;
  
      &lt;TextView
          android:id="@+id/tabText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:visibility="visible" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>layout-port\tab_header.xml (<code>TextView</code> is gone)</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal" &gt;
  
      &lt;ImageView
          android:id="@+id/tabIcon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:paddingTop="2dp" 
          android:visibility="visible"/&gt;
  
      &lt;TextView
          android:id="@+id/tabText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:visibility="gone" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>But the results are confusing. (I've got screenshots, but I am not allowed to post them yet, sorry).</p>
  
  <ul>
  <li>When the application starts in portrait, Tabs are viewed as images.</li>
  <li>After the device is rotated, Tabs turn into drop-down with text header, as intended.</li>
  <li>But after I change my Tab/Drop-Down, Tabs go back into Tabs, without any content.</li>
  </ul>
  
  <p>Thus the question: what is wrong with the appliaction, and, maybe, with the concept?
  Perhaps, the is some way to control tabs behavior during orientation changes?</p>