Tutorial :How to have Android tabs coexisting with other views?



Question:

I need to have a layout that has a view above a set of tabs. I've gotten the tabs working fine, but as soon as I try to add a view outside of them I'm left with that view and no visible tabs.

This works fine:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="fill_parent"      android:layout_height="fill_parent">      <TabHost           android:id="@android:id/tabhost"          android:layout_width="fill_parent"          android:layout_height="fill_parent"          android:layout_weight="1">          <LinearLayout  ... />  

But this doesn't:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="fill_parent"      android:layout_height="fill_parent">      <TextView  ... />  <!--  THIS LINE HERE!!!  -->      <TabHost           android:id="@android:id/tabhost"          android:layout_width="fill_parent"          android:layout_height="fill_parent"          android:layout_weight="1">          <LinearLayout  ... />  

What can I do to make my tabs co-exist with other views?


For the sake of completeness, my Activity extends TabActivity.


Solution:1

Mayby you should get rid of the initial LinearLayout and start with your tabhost, like in this tutorial? Or is your goal to have a set-up like the image below?

+-----------------+  | App Title       |  +-----------------+  | some text       |  +-----+-----+-----+  | tab | tab | tab |  +-----+-----+-----+  |                 |  


Solution:2

Actually, according to this article, it isn't possible. Grr.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »