简体   繁体   中英

Android FragmentActivity inside Tabhost?

I'm trying to implement an app with the following specs:

A tabhost inside a main fragmentActivity. In each of those tabs, there is a fragment.

In tab B, I have a ListFragment. I want to be able to click on a list element and have a new fragment open in the same tab OVER the list. But I do not want this fragment to take over the entire screen; I still want to be able to switch tabs with the new fragment open. I also want to be able to close the new fragment and see the list again.

How should I go about implementing this? I tried replacing the fragment of tab B with a fragmentActivity so I could handle the transition between the fragments, but the tabhost complained.

Is there some way to launch another fragment (that takes over the current fragment's location in the activity) from tab B? I want to be able to close the new fragment and go back to the list of tab B.

Update: I figured it out! There's something called fragment backstacks.

Answer: use fragment backstacks! you can do it from within the fragment you want to replace!

http://developer.android.com/guide/topics/fundamentals/fragments.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM