0

I have a tabhost which contains 3 tabs.These 3 tabs connected with 3 activity.All 3 tabs are in upper side.How can i make these 3 tabs in buttom.Is there any way in android?

This is my tabhost xml file.

<?xml version="1.0" encoding="UTF-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    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">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" />
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_weight="0"/>


    </LinearLayout>
</TabHost>

in my TabActivity class i have following code:

setContentView(R.layout.tabs);

       TabHost mTabHost = (TabHost)findViewById(android.R.id.tabhost);

        mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class)));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class)));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class)));

        mTabHost.setCurrentTab(0);

There is one activity named TabActivity1 which i have also included in Manifest file.But it is showing error cant get the activity TabActivity1.

Android Killer
  • 18,174
  • 13
  • 67
  • 90

1 Answers1

0

I had used the following kind of layout to align the tabs at the bottom, I guess it might work out for you as well.

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

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"/>
            android:padding="5dp"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="#000070"/>
    </LinearLayout>
</TabHost>
SamSPICA
  • 1,366
  • 15
  • 31
  • Ok but i want to create more than one tabs where each tab will contain one activty.i m doing this TabHost mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class))); But it is showing error cant get activity TabActivity1. – Android Killer Aug 18 '11 at 06:45
  • Don't forget to define each activity in the Android Manifest file. – SamSPICA Aug 18 '11 at 09:46