Android uses fragmenttabhost instead of tabhost

Android uses fragmenttabhost instead of tabhost

preface:

Now fragment is used more and more widely. Although fragment is parasitic under activity, its emergence is a very lucky thing for developers to make development more efficient. Well, let's talk about the use of fragment tabhost, because tabhost is not recommended. Now fragment tabhost is generally used! I'm also a rookie. I'm just helping novices, because fragment only appears in 3.0. In order to avoid using less than 3.0, we need to use V4 package to support it. Don't pour the wrong package! God, don't spray!

1: First, let's look at XML:

1.activity_ main.xml

2.tab_ item_ view.xml

3. Fragment1.xml just paste a fragment XML! The others are the same, but the color is different, ha ha!

OK, XML is finished first. Let's look at the code!

4.MainActivity

5. Fragment1.java fragment is the same as others, but XML is different!

OK, basically finished. Let's see the effect!

Ha ha, the effect is OK! All right, let's go to dinner!

Resource download address: http://xiazai.jb51.net/201705/yuanma/FragmentTabhost (jb51.net).rar

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>