Note that there are some explanatory texts on larger screens.

plurals
  1. POTabHost android isn't working correctly
    text
    copied!<p>I am trying to get this TabHost to work. When I add the TabHost to the xml layout and run the program I can see the different content for each tab stacked on top of each other. This tells me that the layout is working properly. I then add my spec code to the activity and then if closes the program on the emulator when I navigate to this screen.<br> So here is my XML:</p> <pre><code>&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;TextView android:id="@+id/tWelcome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Large Text" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;Button android:id="@+id/bNewTask" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Task" /&gt; &lt;TabHost android:id="@+id/myTabs" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;TabWidget android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/TabWidget&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;LinearLayout android:id="@+id/tab1" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/tab2" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;TextView android:id="@+id/tTest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/LinearLayout&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; &lt;/LinearLayout&gt; </code></pre> <p>Here now is my Activity code: (The only part that matters...)</p> <pre><code> welcomeName = (TextView) findViewById(R.id.tWelcome); Test = (TextView) findViewById(R.id.tTest); newTask = (Button) findViewById(R.id.bNewTask); myTask = (ListView) findViewById(R.id.listView); TabHost th = (TabHost) findViewById(R.id.myTabs); welcomeName.setText("Welcome " + ToDoActivity.myUser.getName() + "!"); th.setup(); TabSpec specs = th.newTabSpec("tag1"); specs.setContent(R.id.tab1); specs.setIndicator("All"); th.addTab(specs); specs = th.newTabSpec("tag2"); specs.setContent(R.id.tab2); specs.setIndicator("Personal"); th.addTab(specs); </code></pre>
 

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