最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android選項(xiàng)卡TabHost功能用法詳解

 更新時(shí)間:2022年04月24日 11:27:25   作者:被遺忘的秋天  
這篇文章主要為大家詳細(xì)介紹了android選項(xiàng)卡TabHost的功能用法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了android選項(xiàng)卡TabHost功能用法,供大家參考,具體內(nèi)容如下

首先定義三個(gè)xml文件,分別為l1.xml,l2.xml,l3.xml,每個(gè)選項(xiàng)卡的標(biāo)簽頁(yè)的內(nèi)容為一個(gè)xml文件。

其中l(wèi)1.xml為:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:orientation="vertical"?
? ? android:id="@+id/l1">
?
? ? <Button
? ? ? ? android:id="@+id/button1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:text="Button" />
?
</LinearLayout>

l2.xml為:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:orientation="vertical"?
? ? android:id="@+id/l2">
?
? ? <EditText
? ? ? ? android:id="@+id/editText1"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:ems="10"
? ? ? ? android:inputType="textPersonName" >
?
? ? ? ? <requestFocus />
? ? </EditText>
?
? ? <EditText
? ? ? ? android:id="@+id/editText2"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:ems="10"
? ? ? ? android:inputType="textPassword" />
?
</LinearLayout>

l3.xml為:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:orientation="vertical"
? ? android:id="@+id/l3">
?
? ? <RatingBar
? ? ? ? android:id="@+id/ratingBar1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content" />
?
</LinearLayout>

TabActivityDemo2.java:

package com.example.wenandroid;
?
import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost.TabSpec;
?
public class TabActivityDemo2 extends TabActivity {
?
?? ?protected void onCreate(Bundle savedInstanceState) {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?super.onCreate(savedInstanceState);
?? ??? ?android.widget.TabHost tab=getTabHost();
?? ??? ?LayoutInflater lay=LayoutInflater.from(this);
?? ??? ?lay.inflate(R.layout.l1, tab.getTabContentView(),true);
?? ??? ?lay.inflate(R.layout.l2, tab.getTabContentView(),true);
?? ??? ?lay.inflate(R.layout.l3, tab.getTabContentView(),true);
?? ??? ?
?? ??? ?TabSpec t1=tab.newTabSpec("t1");
?? ??? ?TabSpec t2=tab.newTabSpec("t2");
?? ??? ?TabSpec t3=tab.newTabSpec("t3");
?? ??? ?
?? ??? ?t1.setIndicator("選項(xiàng)卡1");
?? ??? ?t2.setIndicator("選項(xiàng)卡2");
?? ??? ?t3.setIndicator("選項(xiàng)卡3");
?? ??? ?
?? ??? ?t1.setContent(R.id.l1);
?? ??? ?t2.setContent(R.id.l2);
?? ??? ?t3.setContent(R.id.l3);
?? ??? ?
?? ??? ?tab.addTab(t1);
?? ??? ?tab.addTab(t2);
?? ??? ?tab.addTab(t3);
?? ?}
?
}

效果如下圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

保山市| 苍山县| 长治县| 来凤县| 如皋市| 南通市| 丰城市| 黑龙江省| 荥经县| 色达县| 山阳县| 海晏县| 旺苍县| 临邑县| 绥阳县| 兰考县| 长沙县| 乌海市| 尼勒克县| 乌兰察布市| 偃师市| 诸暨市| 黄大仙区| 宁武县| 察雅县| 郓城县| 秀山| 金川县| 郑州市| 凤城市| 天等县| 新巴尔虎左旗| 天峨县| 三河市| 佛冈县| 交口县| 郴州市| 焉耆| 乃东县| 余干县| 南木林县|