Android TabHost inside Fragment
Asked Answered
C

3

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.

Changeup answered 31/12, 2011 at 13:19 Comment(1)
This Answer Here Is Great Check It: https://mcmap.net/q/420227/-adding-tab-inside-fragment-in-androidScarlettscarp
S
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/

Semiramis answered 31/12, 2011 at 14:2 Comment(7)
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.Changeup
@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.Dion
@Architact can you share the solution ?Danziger
@HarshaMV. are you facing exactly the same problem as I posted?Changeup
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: dl.dropbox.com/u/55770184/concessions.zip, Sorry for my bad coding as it was quite an urgent task.Changeup
@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 mapDanziger
@Architact You should unaccept this answer... It is not relevant to your question...Hertel
M
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

Macadam answered 7/3, 2014 at 12:34 Comment(1)
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 thisWigeon
I
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.

Ilene answered 14/12, 2012 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.