Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Fragment combined with FragmentTabHost

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report