Elior
Elior

Reputation: 3266

Nested tabhost fragment android

I have an application with 3 screens, each screen is a fragment. I want that in 1 screen there will be 2 other screens. for example:

| TAB 1 | TAB 2 | TAB 3 |

now when you are in TAB 1

you will see

| INNER_TAB 1 | INNER_TAB 2 |

This is how I tried to implement it:

  1. Main Activity which extends FragmentActivity
  2. I have 3 Fragments (classes) - one for each tab
  3. In the MainActivity I added the tabs into the tab host.
  4. I tried to create that one Fragment from step 2 will extend FragmentActivity, so I could add inner
    tabs to this fragment.
  5. Everything is compile as well.
  6. Run the application and press the first tab to see the inner tabs and - exception - can't cast fragmentActivity to fragment.

Upvotes: 1

Views: 603

Answers (1)

Elior
Elior

Reputation: 3266

After a while I came with a solution.

As I said each fragment has its own class and layout, so in Tab1 layout I added FragmentTabHost. And in onCreateView method of Tab1 I initializing the FragmentTabHost and adding the inner tabs for it.

Upvotes: 1

Related Questions