Android: creating tabs inside a fragment

This question is a little hard to say, I will try my best.

I have this Android app that uses a navigation box, so in main_activity the navigation box changes the different types of fragments that I want.

Inside one fragment, I want it to have four tabs. The functionality of the tabs is very simple, since basically some images and data are simply displayed. However, I do not think that android allows you to have a taboo inside the fragment.

I can achieve a similar result by creating my own buttons at the top and dynamically changing the view inside this fragment, however, I wonder if there is a more intuitive way to achieve the same result?

+4
source share
1 answer

You can easily use TabHostinside Fragment. A is TabActivitynot required to place tabs. TabActivityprovides only some functions that you can also add in Fragmentyourself. Check out the TabHost docs, especially the addTab () section . You can also search here on SO, and you will find very useful posts such as this one .

+3
source

All Articles