Question

This question is a bit hard to word, I will try my best.

I have this android app that uses a navigation drawer, so within the main_activity, the navigation drawer would change the different kinds of fragments that I want.

Within one fragment, I want it to be able to have four tabs. The functionality of the tabs is very simple as it basically just display some pictures and data. However, I don't think android allows you to have a tabhost within a fragment.

I can achieve a similar result by creating my own buttons at the top and it dynamically changes the View that is within this fragment, however, I am wondering is there a more intuitive way of achievement the same result?

Was it helpful?

Solution

You can use TabHost inside a Fragment just fine. A TabActivity is not necessary to host the tabs. TabActivity only provides some functionality that you can also add to a Fragment yourself. Check out the TabHost docs, especially the section about addTab(). You can also search here on SO and you will find very helpful posts like this one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top