0

I'm working with TabHost and I want to have two tabs, but everything I have in second tab is in first tab and there is no tab button to be clicked. Here is how it looks like. I just dragged and dropped tabhost in Design editor in IDEA

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent">


    <TabHost
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:id="@+id/tabHost2" android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true">
        <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">
            <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content">
            </TabWidget>
            <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent">
                <LinearLayout
                        android:id="@+id/linearLayout2"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:orientation="vertical">
                    <Button
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:text="Button1"
                            android:id="@+id/button2"/>
                </LinearLayout>
                <LinearLayout
                        android:id="@+id/linearLayout"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:orientation="vertical" >
                    <Button
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Button2"
                            android:id="@+id/button3"/>
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</RelativeLayout>

And then I just add button to first and second linear layout. But like I said. Everything is in first layout. Could you help me figure it out? Thanks :)

miskohut
  • 957
  • 1
  • 14
  • 34

1 Answers1

0

At start read this : http://www.learn-android-easily.com/2013/07/android-tabwidget-example.html. This is for begginers.

GIGAMOLE
  • 1,274
  • 1
  • 11
  • 17