欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Fragment結(jié)合FragmentTabHost怎么用

這篇文章主要介紹Fragment結(jié)合FragmentTabHost怎么用,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:申請(qǐng)域名雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、鐵山網(wǎng)站維護(hù)、網(wǎng)站推廣。

FragmentTabHost我也不知道是什么,就是可用用來當(dāng)新浪微博底部那個(gè)狀態(tài)欄的工具。現(xiàn)在說下怎么使用

首先activity要繼承FragmentActivity

例如

public class A extends FragmentActivity{

//定義FragmentTabhost

private FragmentTabhost tab;

private TextView text;

private String str[]={"短信","電話","黑白名單","設(shè)置"};

private int icon[]={R.drawable.ic_firewall_sms_desk_setting,R.drawable.firewall_tab_icon_phone,R.drawable.sync_register_icon,R.drawable.img1};

private Class fragments[]={Fragment1.class,Fragment2.class,Fragment3.class,Fragment5.class};

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.harassment_intercepion);//主界面下面放出這個(gè)節(jié)目的XML文件

iniView();

}

}

=================================================================

<?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:orientation="vertical"

   android:background="#333333"

   >

   <RelativeLayout

       android:layout_width="fill_parent"

   android:layout_height="fill_parent"

   android:id="@+id/up_frame"

       >

   <android.support.v4.app.FragmentTabHost   //這個(gè)是tabhost的組件

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

       android:layout_width="fill_parent"

       android:layout_height="wrap_content"

     android:layout_alignParentBottom="true"

       >

       <FrameLayout

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

           android:layout_width="0dp"

           android:layout_height="0dp"

           android:layout_weight="0" />            

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

   </RelativeLayout>

</RelativeLayout>

==========================================================================

然后實(shí)例化組件

public void init()

tab=this.findById(android.R.id.tabhost);//實(shí)例化tabhost

//tabhost.setup 第一個(gè)參數(shù)是context,第二個(gè)是拿到父類,第三個(gè)是

tabhost.setup(this, getSupportFragmentManager(), R.id.up_frame);外面包圍tabhost的Rlayout

//

說說與Fragment結(jié)合。

具體使用到下面這個(gè)方法

int count=fragments.length;//拿到多少個(gè)fragment

for(int i=0;i<count;i++){

TabSpec spec=tab.newTabSpec(str[i]).setIndicator(getTabItemView(i));

tab.addTab(spec,fragments[i],null);//把點(diǎn)擊的tab與fragment連接起來

}

}

////////////

private View getTabItemView(int index){

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

p_w_picpath=(ImageView) view.findViewById(R.id.fragment_p_w_picpath);

text=(TextView) view.findViewById(R.id.fragment_text);

p_w_picpath.setImageResource(icon[index]);

text.setText(str[index]);

return view;

}

以上是“Fragment結(jié)合FragmentTabHost怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站題目:Fragment結(jié)合FragmentTabHost怎么用
當(dāng)前URL:http://www.chinadenli.net/article0/joegio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作虛擬主機(jī)定制網(wǎng)站外貿(mào)網(wǎng)站建設(shè)App開發(fā)用戶體驗(yàn)

廣告

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

搜索引擎優(yōu)化