成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

關于FragmentTabHost的使用-創(chuàng)新互聯(lián)

近期剛學了Fragment,突然想在Fragment中實現TabHost,查閱相關資料后發(fā)現現在TabHost已經被FragmentTabHost替代了,因此就想著學習一下,并記錄下來,接下來把一些心得分享一下。

網站建設哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網頁設計、網站建設、微信開發(fā)、成都微信小程序、集團企業(yè)網站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了清河免費建站歡迎大家使用!

一、使用場景

    首先FragmentTabHost不僅可以在FragmentActivity中使用,也可以在Fragment中使用,通過與Fragment的結合實現TabHost的效果

二、使用步驟

  1、布局文件

    <?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout

      xmlns:android="http://schemas.android.com/apk/res/android"

      android:layout_width="match_parent"

      android:layout_height="match_parent" >

      <android.support.v4.app.FragmentTabHost

       android:id="@android:id/tabhost"

       android:layout_width="match_parent"

       android:layout_height="wrap_content">

       <LinearLayout

          android:layout_width="match_parent"

          android:layout_height="match_parent"

          android:orientation="vertical" >

          <TabWidget

            android:id="@android:id/tabs"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_weight="0"

            android:orientation="horizontal" />

          <FrameLayout

            android:id="@android:id/tabcontent"

            android:layout_width="0dp"

            android:layout_height="0dp"

            android:layout_weight="0" />

          <FrameLayout

            android:id="@+id/realtabcontent"

            android:layout_width="match_parent"

            android:layout_height="0dp"

            android:layout_weight="1" />

        </LinearLayout>

      </android.support.v4.app.FragmentTabHost>

    </RelativeLayout>

    2、代碼:

        1)繼承FragmentActivity——OnCreate()中:

            FragmentTabHost fragmentTabHost =                                                      (FragmentTabHost)findViewById(android.R.id.tabhost);

      fragmentTabHost.setup(this, getFragmentManager(), R.id.realtabcontent);

      fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab1").setIndicator("我的意                     見"), SettingFragment.class, null);

      fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab2").setIndicator("常見問                     題"), NotificationFragment.class, null);

        2)繼承Fragment——OnCreateView()中:

       View layout = inflater.inflate(R.layout.fragment_sliding_feedback, null);

       FragmentTabHost fragmentTabHost =                                       (FragmentTabHost)layout.findViewById(android.R.id.tabhost);

      fragmentTabHost.setup(this, getChildFragmentManager(), R.id.realtabcontent);

      fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab1").setIndicator("我的意                     見"), SettingFragment.class, null);

      fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab2").setIndicator("常見問                     題"), NotificationFragment.class, null);

      return layout;

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

網站名稱:關于FragmentTabHost的使用-創(chuàng)新互聯(lián)
標題來源:http://jinyejixie.com/article12/diosdc.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供域名注冊、網站策劃、外貿建站、標簽優(yōu)化、云服務器商城網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網站優(yōu)化
靖安县| 天水市| 竹山县| 屏东市| 文化| 平谷区| 桐乡市| 凤城市| 米易县| 保亭| 榆社县| 德江县| 会泽县| 乌海市| 出国| 会泽县| 全南县| 常州市| 繁峙县| 随州市| 牡丹江市| 鸡东县| 庄浪县| 虞城县| 阜宁县| 巴南区| 巴南区| 宜兰县| 宁明县| 屯留县| 台山市| 本溪市| 蓬莱市| 孝昌县| 肃北| 尚志市| 邢台县| 布拖县| 宽城| 舒兰市| 吉首市|