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

android TabHost(選項(xiàng)卡)的使用方法

 更新時(shí)間:2013年11月19日 11:18:36   作者:  
Android中的選項(xiàng)卡是用TabHost實(shí)現(xiàn)的,下面我們用一個(gè)例子說(shuō)明他的使用方法

首先,定義TabHost的布局文件:

復(fù)制代碼 代碼如下:

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

        <TabWidget android:id="@android:id/tabs"
            android:layout_alignParentBottom="true"
            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" />

    </LinearLayout>

</TabHost>

其中,TabWidget即是選項(xiàng)卡上面的標(biāo)簽,F(xiàn)rameLayout是選項(xiàng)卡的內(nèi)容。
在Java類文件中定義如下:

復(fù)制代碼 代碼如下:

public class MainActivity extends TabActivity {

    private TabHost my_tabhost; 
    private TabWidget my_tabwidget;
    private int i,k;
    private TextView tv;

    private String[] tabMenu = { "系統(tǒng)", "硬件", "操作"};
    private Intent intent0, intent1, intent2;
    private Intent[] intents = { intent0, intent1, intent2};
    private TabHost.TabSpec tabSpec0, tabSpec1, tabSpec2, tabSpec3;
    private TabHost.TabSpec[] tabSpecs = { tabSpec0, tabSpec1, tabSpec2, tabSpec3};

    public static Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
                // 不要窗體標(biāo)題
               requestWindowFeature(Window.FEATURE_NO_TITLE);
               setContentView(R.layout.activity_main);
        setContentView(R.layout.activity_main);

        my_tabhost = getTabHost();

        intent0 = new Intent(this, system.class);
        intent1 = new Intent(this, hardware.class);
        intent2 = new Intent(this, operation.class);

        tabSpec0 = my_tabhost.newTabSpec("system").setIndicator(tabMenu[0],null).
                setContent(intent0);
        tabSpec1 = my_tabhost.newTabSpec("hardware").setIndicator(tabMenu[1],null).
                setContent(intent1);
        tabSpec2 = my_tabhost.newTabSpec("operation").setIndicator(tabMenu[2],null).
                setContent(intent2);

        my_tabhost.addTab(tabSpec1);
        my_tabhost.addTab(tabSpec0);
        my_tabhost.addTab(tabSpec2);
<br>                 // 設(shè)置默認(rèn)選中的選項(xiàng)卡為第2個(gè)      
                     my_tabhost.setCurrentTab(1);

    }

}

每一個(gè)選項(xiàng)卡對(duì)應(yīng)一個(gè)Intent,每一個(gè)Intent又對(duì)應(yīng)一個(gè)類,選中這個(gè)選項(xiàng)卡時(shí),就顯示對(duì)應(yīng)的類。
運(yùn)行結(jié)果如下:

相關(guān)文章

  • android的got表HOOK實(shí)現(xiàn)代碼

    android的got表HOOK實(shí)現(xiàn)代碼

    對(duì)于android的so文件的hook根據(jù)ELF文件特性分為:Got表hook、Sym表hook和inline hook等。今天通過(guò)本文給大家介紹android HOOK實(shí)現(xiàn)got表的實(shí)例代碼,需要的朋友參考下吧
    2021-08-08
  • 利用Android設(shè)計(jì)一個(gè)倒計(jì)時(shí)組件

    利用Android設(shè)計(jì)一個(gè)倒計(jì)時(shí)組件

    在很多電商工作項(xiàng)目中經(jīng)常有倒計(jì)時(shí)的場(chǎng)景,比如活動(dòng)倒計(jì)時(shí)、搶紅包倒計(jì)時(shí)等等,今天小編就帶大家來(lái)學(xué)習(xí)如何利用Android設(shè)計(jì)倒計(jì)時(shí)組件,感興趣的小伙伴一起奧
    2021-09-09
  • Android性能優(yōu)化之JVMTI與內(nèi)存分配

    Android性能優(yōu)化之JVMTI與內(nèi)存分配

    這篇文章主要為大家介紹了Android性能優(yōu)化之JVMTI與內(nèi)存分配,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • Android便攜式熱點(diǎn)的開(kāi)啟狀態(tài)檢測(cè)和SSID的獲取方法

    Android便攜式熱點(diǎn)的開(kāi)啟狀態(tài)檢測(cè)和SSID的獲取方法

    WIFI熱點(diǎn)的開(kāi)啟狀態(tài)和開(kāi)啟后的SSID如何獲取呢?接下來(lái)通過(guò)本文給大家分享Android便攜式熱點(diǎn)的開(kāi)啟狀態(tài)檢測(cè)和SSID的獲取方法,需要的朋友參考下吧
    2017-01-01
  • Android中Intent傳遞對(duì)象的3種方式詳解

    Android中Intent傳遞對(duì)象的3種方式詳解

    這篇文章給大家介紹了Android中Intent傳遞對(duì)象的3種方式,分別是Serializable 方式、Parcelable 方式以及JSON 方式,有需要的朋友們可以一起參考借鑒,下面來(lái)一起看看吧。
    2016-09-09
  • Android videoview搶占焦點(diǎn)的處理方法

    Android videoview搶占焦點(diǎn)的處理方法

    這篇文章主要為大家詳細(xì)介紹了Android videoview搶占焦點(diǎn)的處理方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • android實(shí)現(xiàn)okHttp的get和post請(qǐng)求的簡(jiǎn)單封裝與使用

    android實(shí)現(xiàn)okHttp的get和post請(qǐng)求的簡(jiǎn)單封裝與使用

    這篇文章主要介紹了android實(shí)現(xiàn)okHttp的get和post請(qǐng)求的簡(jiǎn)單封裝與使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-05-05
  • Android中外接鍵盤的檢測(cè)的實(shí)現(xiàn)

    Android中外接鍵盤的檢測(cè)的實(shí)現(xiàn)

    這篇文章主要介紹了Android中外接鍵盤的檢測(cè)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • android實(shí)現(xiàn)彈出提示框

    android實(shí)現(xiàn)彈出提示框

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)彈出提示框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-01-01
  • Android Studio獲取網(wǎng)絡(luò)JSON數(shù)據(jù)并處理的方法

    Android Studio獲取網(wǎng)絡(luò)JSON數(shù)據(jù)并處理的方法

    這篇文章主要為大家詳細(xì)介紹了Android Studio獲取網(wǎng)絡(luò)JSON數(shù)據(jù)并處理的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10

最新評(píng)論

齐河县| 阿鲁科尔沁旗| 崇文区| 兴安县| 乳源| 大渡口区| 兰溪市| 东乡县| 兴宁市| 新竹县| 南开区| 奇台县| 沂南县| 腾冲县| 绵竹市| 鹿邑县| 嘉祥县| 神木县| 遵义市| 海门市| 双柏县| 河池市| 宣汉县| 溆浦县| 孝感市| 泽州县| 丽江市| 大港区| 定南县| 曲松县| 正定县| 惠东县| 永靖县| 苏尼特左旗| 余干县| 临汾市| 南乐县| 尉犁县| 芮城县| 常德市| 定西市|