2

i want add tabs inside tab like below:

 ----------------------
|Tab 1 | Tab 2 | tab 3 |
-----------------------
| Sub tab 1 | Sub tab 2|
 ----------------------

Each Parent tab has two sub tab. I am using fragment to display Parent tab(Action Bar tab).

I tried this by implementing fragment replace but android doesn't support nested fragment (except 17+). How can i get this done.Please help me out to solve this.

<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.view.PagerTitleStrip
    android:id="@+id/pager_title_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="#33b5e5"
    android:textColor="#fff"
    android:paddingTop="4dp"
    android:paddingBottom="4dp" />

</android.support.v4.view.ViewPager>
rupesh
  • 2,865
  • 4
  • 24
  • 50

2 Answers2

1

You may been able to do that if the sub tabs are views and not fragments. Usign TabHost, TabWidget, a FrameLayout with id "@android:id/tabcontent" with the different tabs inside.

Heisenberg
  • 656
  • 7
  • 10
0

You can disguise RadioButton to look like tabs and add as many layers as you want. This offers even higher flexibility in looks than the android inbuilt version. The RadioGroup ensures that only 1 is selected at a time. Check out the accepted answer Making buttons that look like tabs in android for implementation.

Community
  • 1
  • 1
Shakti
  • 1,581
  • 2
  • 20
  • 33
  • could you please explain this? – rupesh May 08 '14 at 09:24
  • basic functionality of tab to have one item selected at a time and using that info you can load content on the rest of the page. – Shakti May 08 '14 at 09:25
  • you want me to put radio button inside fragment? – rupesh May 08 '14 at 09:26
  • How the fragment XML will look like? – rupesh May 08 '14 at 09:27
  • Don't use fragment to display parent tab. Add two layers of radio groups one after the other. Fetch value from first layer to update second layer and fetch value from second layer to do what you want with rest of the page. The radio button is just an image and hence can be changed to active/inactive image of tab button. There are lot of examples on how to do it including the one i linked. – Shakti May 08 '14 at 09:29
  • could please give some other links related to this. – rupesh May 08 '14 at 09:33
  • http://www.phonesdevelopers.com/1772557/ and http://stackoverflow.com/questions/17540111/making-buttons-that-look-like-tabs-in-android will put you in the right direction i hope. – Shakti May 08 '14 at 09:39