Second set of tabs in an Android fragment

522 views Asked by At

I want to add a second row of tabs to my Android application on the second fragment accessed from the ActionBar tabs.

enter image description here

Tab 1 shows fragment 1.

Tab 2 shows fragment 2 but I would like fragment 2 to have a second row of tabs so it will show fragment a or b.

But it seems like fragments within fragments cannot be done and an ActionBar submenu can't be switched on or off. I have also tried with a FragmentStatePagerAdapter with a TabHost and a ViewPager which displays the tabs fine but does not display the fragments. Is there any other way to do this?

1

There are 1 answers

0
Moinkhan On BEST ANSWER

If you know the new Design Support Library .... In your second fragment you can use TabLayout introduced in design support library 22 . Which is same as Actionbar tabs.

So just add the TabLayout in your second fragment XML.

And TabLayout has a method setUpWithViewPager(). So you can easily setup your tabs.

I hope it helps you. here is the reference http://android-developers.blogspot.in/2015/05/android-design-support-library.html