简体   繁体   English

Tabhost内的Android FragmentActivity?

[英]Android FragmentActivity inside Tabhost?

I'm trying to implement an app with the following specs: 我正在尝试使用以下规格实现应用:

A tabhost inside a main fragmentActivity. 主fragmentActivity中的tabhost。 In each of those tabs, there is a fragment. 在每个选项卡中,都有一个片段。

In tab B, I have a ListFragment. 在选项卡B中,我有一个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. 我尝试用fragmentActivity替换选项卡B的片段,以便可以处理片段之间的过渡,但是tabhost抱怨。

Is there some way to launch another fragment (that takes over the current fragment's location in the activity) from tab B? 是否可以通过选项卡B启动其他片段(接管当前片段在活动中的位置)? I want to be able to close the new fragment and go back to the list of tab B. 我希望能够关闭新片段并返回到选项卡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 http://developer.android.com/guide/topics/fundamentals/fragments.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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