How can I use fragments, now that TabActivity is deprecated?

巧了我就是萌 提交于 2019-12-08 07:17:16

问题


I have a main activity with a sort of dock at the bottom, with 4 icons: A, B, C, D.

I already tried getting a response to a question here involving replacing a fragment within a given tab but did not get an answer. I began to think that maybe I was heading down a wrong path. So now I thought up a new way of implementing it which basically forces me to use the now deprecated TabActivity. The question is, why is it deprecated?

My idea is to implement a system as such :

TabActicity(TabActivity)
Tab A(FragmentActivity) -> Fragments
Tab B(FragmentActivity) -> Fragments
Tab C(FragmentActivity) -> Fragments
Tab D(FragmentActivity) -> Fragments

Meaning each Tab has its own fragmentActivity that its fragments. Is this the way of implementing the system instead of having a FragmentActivity as my TabController and using fragments as each individual tab ?


回答1:


In the Android docs you find an example of how to use a TabHost with Fragments. No TabActivity needed. Here is the example: http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.html



来源:https://stackoverflow.com/questions/9871038/how-can-i-use-fragments-now-that-tabactivity-is-deprecated

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