8

I am working on an Android App and I have used android FragmentPager tabs example from developer.android.com), this example uses fragments for tabs contents, Now I want to place a tabHost inside one of those fragments, I have tried my best but the second tab hosts are not showing the content, I can see tab headers but no content, I am trying to use Intents as TabContent. I don't think I have any relevant code to post here, but If you need I can post it here.

The hierarchy is: FragmentActivity->TabHost->Fragments->TabHost->(Intent or Fragment, this is the problem area)

Any Suggestion would be appreciated.

TilalHusain
  • 1,006
  • 5
  • 17
  • 36
  • This Answer Here Is Great Check It: [http://stackoverflow.com/a/21605672/3484700](http://stackoverflow.com/a/21605672/3484700) – Salam El-Banna Mar 05 '16 at 19:09

3 Answers3

4

Now you can use FragmentTabHost

This can also be used inside of a fragment through fragment nesting

http://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html

fabrizotus
  • 2,958
  • 2
  • 21
  • 27
  • Any development ontop of the code provided in this link would be really helpful. There are no working examples of using a FragmentTabHost inside a fragment created by the main activity... None where the mainactivity is using a NavigationDrawer anyway. But I am really new to this – Jethro Feb 16 '16 at 16:20
4

Have you seen this? I've referenced it a few times, should help you out.

http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

adneal
  • 30,484
  • 10
  • 122
  • 151
  • Yes, I have seen that, but my issue is different, my class which contains TabHost is extending from Fragment class not FragmentActivity. But I will give it another shot. – TilalHusain Dec 31 '11 at 14:23
  • @Architact Did you find that this process worked? I too am trying to add a TabHost with 2 tabs into a Fragment. It looks like you can use the same logic but add the TabHost and its controller to the Fragment. – jamis0n Nov 14 '12 at 16:21
  • @Architact can you share the solution ? – Harsha M V Dec 07 '12 at 12:21
  • @HarshaMV. are you facing exactly the same problem as I posted? – TilalHusain Dec 07 '12 at 16:57
  • I don't exactly remember how I fixed this issue because it is almost a year old now, I have uploaded the relavant parts of code here: http://dl.dropbox.com/u/55770184/concessions.zip, Sorry for my bad coding as it was quite an urgent task. – TilalHusain Dec 07 '12 at 17:14
  • @Architact yeah its similar. i have a Fragment Activity n whcih has a tab host and in one i want to place a view pager and other i want map – Harsha M V Dec 07 '12 at 18:11
  • @Architact You should unaccept this answer... It is not relevant to your question... – hendrix Feb 11 '13 at 18:56
1

I face the same problem we. We cannot open a fragment or activity in another tab.(We an but it will open in the same tab). So i am use to the below code to change the tab.

 MainActivity.tabHost.setCurrentTab(tabIndex);

Its open the tab with the main tab page.

Akhil
  • 303
  • 2
  • 7
  • 19