我有一个 FragmentActivity
名为 MainActivity
持有两个片段,一个菜单的片段向左和应用一个内容片段到右侧。在一个大的设备这两个片段被示出。上的小设备只有菜单片段被示出并当用户presses在所述菜单中的内容片段中显示一个新的活动的项目
I have an application with an FragmentActivity
called MainActivity
which holds two fragments, one menu fragment to the left and one content fragment to the right. On a large device both of these fragments are shown. On a small device only the menu fragment is shown and when the user presses an item in said menu the content fragment is displayed in a new Activity
.
让我们说的用户当前正在使用他的电话中的应用,只有菜单可见:
Lets say the user is currently using the application on his phone and only the menu is visible:
在动作条
MainActivity
可以由用户选择的菜单进行操作。当用户选择一个特定的菜单项,一个新的活动
启动要显示的内容片段。当此活动
弹出的动作条
新活动的
是一个新的动作条
,因此没有类似于动作条
的 FragmentActivity
( MainActivity
)。
The ActionBar
of MainActivity
can be manipulated by user choices in the menu. When the user selects a specific menu item, a new Activity
launches to display the content fragment. When this Activity
pops up the ActionBar
of this new Activity
is a new ActionBar
and therefore does not resemble the ActionBar
of FragmentActivity
(MainActivity
).
我想我可以通过动作条
从 MainActivity
到活动
它通过意图
其他显示内容片段,或使动作条
的静态和引用它像 MainActivity.actionBar
或类似的,但我很快就遇到了麻烦:)
I figured I could pass the ActionBar
from MainActivity
to the Activity
which displays the content fragment through Intent
extras, or making the ActionBar
static and reference it like MainActivity.actionBar
or similar, but I ran into problems very quickly :)
在如何解决这个有什么建议?基本上,我要的是分享我的所有活动之间的单个动作条
引用。
Any suggestions on how to solve this? Basically, what I want is to share a single ActionBar
reference between all my activities.
也许这是最好用的片段,而不是活动。我的意思是显示菜单片段
,当你需要显示内容片段
只是把内容片段
进位(容器)在那里有菜单片段
。我认为更好的/更容易组织片段替换/修改逻辑不是尝试不同的活动之间共享动作条。
Maybe it's better to use fragments instead of activities. I mean show menu fragment
, and when you need to show content fragment
just put content fragment
into the place (container) where was menu fragment
. I think better/easier to organize fragment replace/change logics than trying to share actionbar between different activities.