Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: TabHost without TabActivity
    text
    copied!<p>I want to create tabs <strong>without</strong> extending TabActivity. (The reason is that TabActivity cannot handle a custom titlebar as it seems). I have</p> <pre><code>public class startTab extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mylayout); Resources res = getResources(); LocalActivityManager mlam = new LocalActivityManager(this, false); TabHost tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(mlam); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, Show1.class); spec = tabHost.newTabSpec("Items").setIndicator("Items", res.getDrawable(R.drawable.items32_ldpi)).setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, Show2.class); spec = tabHost.newTabSpec("Users").setIndicator("Users",res.getDrawable(R.drawable.user32_ldpi)).setContent(intent); tabHost.addTab(spec); } </code></pre> <p>}</p> <p>The error I get is </p> <pre><code> 07-02 07:11:12.715: ERROR/AndroidRuntime(411): Caused by: java.lang.IllegalStateException: Activities can't be added until the containing group has been created. </code></pre> <p>The xml for the view is</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="5dip"&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt;&lt;/TabWidget&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="5dip"&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p>I read somewhere that I have to use a LocalActivityManager, I assume that I am missing something there. Anyone an idea?</p> <p>Thanks!</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