문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top