Monday, 1 April 2013

Tabs Demo - Bottem Tabs

Demo:


1)Tabs Activity:


 package com.venky.tabsdemo4;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class TabsDemo4 extends TabActivity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            TabHost tabHost = getTabHost();

            TabSpec spec1 = tabHost.newTabSpec("Tab1");
            spec1.setIndicator("Tab1");
            Intent intentTab1 = new Intent(this, Tab1Activity.class);
            spec1.setContent(intentTab1);

            TabSpec spec2 = tabHost.newTabSpec("Tab2");
            spec2.setIndicator("Tab2");
            Intent intentTab2 = new Intent(this, Tab2Activity.class);
            spec2.setContent(intentTab2);

            TabSpec spec3 = tabHost.newTabSpec("Tab3");
            spec3.setIndicator("Tab3");
            Intent intentTab3 = new Intent(this, Tab3Activity.class);
            spec3.setContent(intentTab3);

            tabHost.addTab(spec1);
            tabHost.addTab(spec2);
            tabHost.addTab(spec3);

      }
}


2)main.xml:
 
<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" >

    <RelativeLayout
        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"
            android:layout_alignParentBottom="true" />

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

</TabHost>        


3)Download this Project Click Here  
                           

No comments:

Post a Comment