How to use Fragment combined with FragmentTabHost
This article mainly introduces how to use Fragment combined with FragmentTabHost, the article introduces in great detail, has a certain reference value, interested friends must read it!
I don't know what FragmentTabHost is, it's a tool that can be used as the status bar at the bottom of Sina Weibo. Now tell me how to use it.
First of all, activity inherits FragmentActivity.
For example
Public class An extends FragmentActivity {
/ / define FragmentTabhost
Private FragmentTabhost tab
Private TextView text
Private String str [] = {"SMS", "phone", "Black and White list", "Settings"}
Private int icon [] = {R.drawable.icality firewallflowers smsfolk deskpictures settling magic R.drawable.firewallflowers tableships iconpictures phonetics legendary R.drawable.syncfolk registericonfiguryR.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); / / release the XML file of the program under the main interface
IniView ()
}
}
=
=
Then instantiate the component
Public void init ()
Tab=this.findById (android.R.id.tabhost); / / instantiate tabhost
/ / tabhost.setup the first parameter is context, the second is to get the parent class, and the third is
Tabhost.setup (this, getSupportFragmentManager (), R.id.up_frame); Rlayout that surrounds tabhost
/ /
Talk about combining with Fragment.
Specifically use the following method
How many fragment does int count=fragments.length;// get?
For (int iTuno Bandi)