Android TabHost inside Fragment

限于喜欢 提交于 2019-12-18 15:56:40

问题


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.


回答1:


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/




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/8688307/android-tabhost-inside-fragment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!