Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you have separate activities for each page you want to display, you're going to have to extend ActivityGroup for the container activity (the one displaying the tabs), and LocalActivityManager to manage the different embedded activities you want to use.</p> <p>It's kind of complicated, and not documented. I had to read the sourcecode for <a href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/widget/TabHost.java;h=31920e764e6d25523b6dd5ffb1e4087d4d8fa3b0;hb=HEAD" rel="nofollow noreferrer">TabHost</a>.</p> <p>Search for <code>class IntentContentStrategy</code>.</p> <p>Basically, the idea is that you have a container view, and you use LocalActivityManager to load the activity, get it's View, and place it inside the container view.</p> <p>Excerpt from TabHost.java:</p> <pre><code> public View getContentView() { if (mLocalActivityManager == null) { throw new IllegalStateException("Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?"); } final Window w = mLocalActivityManager.startActivity( mTag, mIntent); final View wd = w != null ? w.getDecorView() : null; if (mLaunchedView != wd &amp;&amp; mLaunchedView != null) { if (mLaunchedView.getParent() != null) { mTabContent.removeView(mLaunchedView); } } mLaunchedView = wd; // XXX Set FOCUS_AFTER_DESCENDANTS on embedded activities for now so they can get // focus if none of their children have it. They need focus to be able to // display menu items. // // Replace this with something better when Bug 628886 is fixed... // if (mLaunchedView != null) { mLaunchedView.setVisibility(View.VISIBLE); mLaunchedView.setFocusableInTouchMode(true); ((ViewGroup) mLaunchedView).setDescendantFocusability( FOCUS_AFTER_DESCENDANTS); } return mLaunchedView; } </code></pre> <p>Note: there is a lot of tweaking and weird stuff you have to do to get this stuff to work (notice the bug they reference in the comment there), which is probably why it's not documented. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload