a、TabHost
//*.xml
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:orientation="vertical"
android:id="@+id/ll_main_tab"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:background="@drawable/ic_launcher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:gravity="center"
android:id="@android:id/tabcontent"
android:fadingEdge="none"
android:fadingEdgeLength="0.0dip"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_weight="1.0">
</FrameLayout>
</LinearLayout>
</TabHost>
//*Activity.java
package hy.com;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
public class *Activity extends TabActivity {
private TabHost tabHost;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.*);
tabHost = this.getTabHost();
tabHost.addTab(tabHost.newTabSpec("three").setIndicator("c").setContent(R.id.tabFirst));
tabHost.addTab(tabHost.newTabSpec("two").setIndicator("b").setContent(new Intent().setClass(this, test.class)));
tabHost.setCurrentTab(0);
}
}