我正在尝试使用以下规范实现一个应用程序:
主要fragmentActivity中的tabhost。 在每个选项卡中,都有一个片段。
在选项卡B中,我有一个ListFragment。 我希望能够单击列表元素并在列表中的同一选项卡中打开一个新片段。 但我不希望这个片段占据整个屏幕; 我仍然希望能够在打开新片段的情况下切换标签。 我还希望能够关闭新片段并再次查看列表。
我应该怎么做呢? 我尝试用fragmentActivity替换选项卡B的片段,这样我就可以处理片段之间的转换,但是tabhost抱怨道。
有没有办法从标签B启动另一个片段(接管当前片段在活动中的位置)? 我希望能够关闭新片段并返回选项卡B列表。
更新:我想通了! 有一种称为片段堆栈的东西。
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.
最满意答案
答:使用片段后台堆栈! 你可以从你想要替换的片段中做到这一点!
http://developer.android.com/guide/topics/fundamentals/fragments.html
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
Tabhost里面的Android FragmentActivity?(Android FragmentActivity inside Tabhost?)我正在尝试使用以下规范实现一个应用程序:
主要fragmentActivity中的tabhost。 在每个选项卡中,都有一个片段。
在选项卡B中,我有一个ListFragment。 我希望能够单击列表元素并在列表中的同一选项卡中打开一个新片段。 但我不希望这个片段占据整个屏幕; 我仍然希望能够在打开新片段的情况下切换标签。 我还希望能够关闭新片段并再次查看列表。
我应该怎么做呢? 我尝试用fragmentActivity替换选项卡B的片段,这样我就可以处理片段之间的转换,但是tabhost抱怨道。
有没有办法从标签B启动另一个片段(接管当前片段在活动中的位置)? 我希望能够关闭新片段并返回选项卡B列表。
更新:我想通了! 有一种称为片段堆栈的东西。
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.
最满意答案
答:使用片段后台堆栈! 你可以从你想要替换的片段中做到这一点!
http://developer.android.com/guide/topics/fundamentals/fragments.html
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
发布评论