title: Actionbar and Tabs and Viewpager and Fragments and Screenorientation
body: <p>I'm trying hard to get this work. I want to have an Actionbar with Tabs and a Viewpager. In the Tabs, there shall be one OR two fragments, depending on the screen orientation.</p>
  
  <p>The one OR two fragments have to be (Sherlock)ListFragments.</p>
  
  <p>This works so far. But there isn't any content in the fragments. Not even onCreate or onCreateView from the first fragment is called. </p>
  
  <p>Here the main Activity:</p>
  
  <pre><code>public class tabActivity extends SherlockFragmentActivity
  {
      private ViewPager mViewPager;
      private TabsAdapter mTabsAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
          setTheme(R.style.Theme_Sherlock);
          super.onCreate(savedInstanceState);
  
          mViewPager = new ViewPager(this);
          //mViewPager.setId(R.id.pager);
  
          setContentView(R.layout.main);
  
          ActionBar bar = getSupportActionBar();
          bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
  
          mTabsAdapter = new TabsAdapter(this, mViewPager);
          mTabsAdapter.addTab(bar.newTab().setText("Advanced"),TitlesFragment.class, null);
      }
  </code></pre>
  
  <p>Followed by the mandatory TabsAdapter. I've made it work with ABS. 
  The TitlesFragment:</p>
  
  <pre><code>public static class TitlesFragment extends SherlockListFragment 
  {
      boolean mDualPane;
      int mCurCheckPosition = 0;
  
      @Override
      public void onCreate(Bundle savedInstanceState) 
      {
  
          View detailsFrame = getActivity().findViewById(R.id.details);
          mDualPane = detailsFrame != null &amp;&amp; detailsFrame.getVisibility() == View.VISIBLE;
  
          if (savedInstanceState != null) {
  
              mCurCheckPosition = savedInstanceState.getInt("curChoice", 0);
          }
  
          if (mDualPane) {
  
              getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  
              DetailsFragment details = (DetailsFragment)getFragmentManager().findFragmentById(R.id.details);
  
              if (details == null)
              {
                  details = DetailsFragment.newInstance();
                  FragmentTransaction ft = getFragmentManager().beginTransaction();
                  ft.replace(R.id.details, details);
                  ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
                  ft.commit();
              }
          }
      }
  @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
          View mView = inflater.inflate(R.layout.list_entervalues, container, false);
          Activity mFracmentActivity = super.getSherlockActivity();
          setListAdapter(new SpecListAdapter(mFracmentActivity, Shakespeare.TITLES));
  
          return mView;
      }
  }
  </code></pre>
  
  <p>It doesn't matter if I take the SpecListAdapter or try to call setListAdapter(new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_activated_1, Shakespeare.TITLES)); in the onCreate() method from the TitlesFragment.</p>
  
  <p>main.xml (res/layout):</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" &gt;
      &lt;android.support.v4.view.ViewPager
      android:id="@+id/viewpager"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>main.xml (res/layout-land):</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal" &gt;
      &lt;android.support.v4.view.ViewPager
      android:id="@+id/viewpager"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="1" /&gt;
  
      &lt;FrameLayout android:id="@+id/details" android:layout_weight="1"
              android:layout_width="fill_parent" android:layout_height="fill_parent"
              android:background="?android:attr/detailsElementBackground" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>