Android中如何实现选项卡功能(android,开发技术)

时间:2024-05-03 02:43:48 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

    Android%E4%B8%AD%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E9%80%89%E9%A1%B9%E5%8D%A1%E5%8A%9F%E8%83%BD

< ?xmlversion="1.0"encoding="utf-8"?>

< TabHostxmlns: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">

< 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">

< TextView

android:id="@+id/textview1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="thisisatab"/>

< TextView

android:id="@+id/textview2"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="thisisanothertab"/>

< TextView

android:id="@+id/textview3"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="thisisathirdtab"/>

< /FrameLayout>

< /LinearLayout>

< /TabHost>

< ?xmlversion="1.0"encoding="utf-8"?>

< TabHostxmlns: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">

< 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">

< TextView

android:id="@+id/textview1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="thisisatab"/>

< TextView

android:id="@+id/textview2"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="thisisanothertab"/>

< TextView

android:id="@+id/textview3"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:text="thisisathirdtab"/>

< /FrameLayout>

< /LinearLayout>

< /TabHost>

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

mTabHost=getTabHost();

mTabHost.addTab(mTabHost.newTabSpec("tab_test1").
setIndicator("TAB1").setContent(R.id.textview1));

mTabHost.addTab(mTabHost.newTabSpec("tab_test2").
setIndicator("TAB2").setContent(R.id.textview2));

mTabHost.addTab(mTabHost.newTabSpec("tab_test3").
setIndicator("TAB3").setContent(R.id.textview3));

mTabHost.setCurrentTab(0);

}

本文:Android中如何实现选项卡功能的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:Android中如何保存数据下一篇:

35 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18