Reputation: 2609
I am trying to build a program where users data is displayed in table view while Home,About and Settings are to be displayed in TabLayout just below the table layout but TabLayout is not shown on screen while program runs. Here I have two class file one to display table layout whereas another to display TabLayout.Below is my main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="7dp">
<TextView
android:id="@+id/item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="2dp"
android:textSize="10dp" />
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="@drawable/top_left" android:textColor="#ffffffff"/>
<TextView android:text="Civil Bank " android:paddingLeft="5dp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="@drawable/top_middle" android:textColor="#ffffffff"/>
<TextView android:text="Sunrise Bank" android:paddingLeft="5dp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="@drawable/top_right" android:textColor="#ffffffff"/>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Web user" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="@+id/webuserTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="@+id/S_webuserTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Transfer" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="@+id/transferTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="@+id/S_transferTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff"/>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Cash" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_right" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="@+id/cashTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="@+id/S_cashTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/bottom_left" android:textColor="#ffffffff"/>
</TableRow>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</TableLayout>
</LinearLayout>
Upvotes: 0
Views: 94
Reputation: 693
You have given the width and height of your tablelayout
as fill-parent
.So it would probably occupy the whole space of your linearlayout
. Instead of fill-parent
you have to use wrap-content
. In tabhost you use the property android:layout_below="@+id/yourTableLayout"
.
Upvotes: 1