title: Android FragmentTabHost - Not fully baked yet?
body: <p>I wanted to see if anyone has had success with customization of tabs using FragmentTabHost that comes with the new Android API level 17. </p>
  
  <p>I was excited to be able to nest a tabHost within my ViewPager SherlockFragments, but I'm having trouble doing simple things like moving the tabs to the bottom or changing the layout of the tabs.</p>
  
  <p>Has anyone seen a good example of using this functionality? </p>
  
  <p>This is the only example I could find in the Android docs, and theres just about nothing that describes its use. It also seems to ignore whatever is defined in the layout for <code>R.id.fragment1</code>.</p>
  
  <p>My question I suppose would be if anyone has come across a good tutorial re:FragmentTabHost
  or if they have an idea about how to a) put the nested tabs at the bottom or b) change the layout of said tabs. </p>
  
  <p>I've tried all the usual methods, but since it appears the XML layout file is overridden, I haven't had much luck.</p>
  
  <pre><code>private FragmentTabHost mTabHost;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      setContentView(R.layout.fragment_tabs);
      mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
      mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
  
      mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
              FragmentStackSupport.CountingFragment.class, null);
      mTabHost.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
              LoaderCursorSupport.CursorLoaderListFragment.class, null);
      mTabHost.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
              LoaderCustomSupport.AppListFragment.class, null);
      mTabHost.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
              LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
  
      return mTabHost;
  }
  </code></pre>
  
  <p>After doing some research, it appears there may be a glitch with initializing the FragmentTabHost in the support library. The user <a href="http://code.google.com/p/android/issues/detail?id=40035">here on Google code</a> has provided a suggestion to this:</p>
  
  <p>FragmentTabHost.java</p>
  
  <pre><code>private void initFragmentTabHost(Context context, AttributeSet attrs) {
      TypedArray a = context.obtainStyledAttributes(attrs,
              new int[] { android.R.attr.inflatedId }, 0, 0);
      mContainerId = a.getResourceId(0, 0);
      a.recycle();
  
      super.setOnTabChangedListener(this);
  
      // If owner hasn't made its own view hierarchy, then as a convenience
      // we will construct a standard one here.
  
  
  /***** HERE COMMENT CODE BECAUSE findViewById(android.R.id.tabs) EVERY TIME IS NULL WE HAVE OWN         LAYOUT ******//
  
  
  //        if (findViewById(android.R.id.tabs) == null) {
  //            LinearLayout ll = new LinearLayout(context);
  //            ll.setOrientation(LinearLayout.VERTICAL);
  //            addView(ll, new FrameLayout.LayoutParams(
  //                    ViewGroup.LayoutParams.FILL_PARENT,
  //                    ViewGroup.LayoutParams.FILL_PARENT));
  //
  //            TabWidget tw = new TabWidget(context);
  //            tw.setId(android.R.id.tabs);
  //            tw.setOrientation(TabWidget.HORIZONTAL);
  //            ll.addView(tw, new LinearLayout.LayoutParams(
  //                    ViewGroup.LayoutParams.FILL_PARENT,
  //                    ViewGroup.LayoutParams.WRAP_CONTENT, 0));
  //
  //            FrameLayout fl = new FrameLayout(context);
  //            fl.setId(android.R.id.tabcontent);
  //            ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));
  //
  //            mRealTabContent = fl = new FrameLayout(context);
  //            mRealTabContent.setId(mContainerId);
  //            ll.addView(fl, new LinearLayout.LayoutParams(
  //                    LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
  //        }
  }
  </code></pre>
  
  <p>XML Layout for fragment:</p>
  
  <pre><code>&lt;android.support.v4.app.FragmentTabHost
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;  
      &lt;FrameLayout
          android:id="@android:id/tabcontent"
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:layout_weight="0"/&gt;
      &lt;FrameLayout
          android:id="@+id/realtabcontent"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"/&gt;
      &lt;TabWidget
          android:id="@android:id/tabs"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="0"/&gt;
  
  &lt;/LinearLayout&gt;
  &lt;/android.support.v4.app.FragmentTabHost&gt;
  </code></pre>