Android ActivityGroup 菜单问题 [英] Android ActivityGroup Menu Problem
问题描述
我在使用 ActivityGroup
时遇到一个问题.我在 ActivityGroup
中有两个活动,它们都使用一个菜单(覆盖 onCreateOptionMenu 和 onOptionsItemSelected).
I have one problem using ActivityGroup
. I have two activities inside an ActivityGroup
and both of them use a menu (overriding the onCreateOptionMenu and onOptionsItemSelected).
嗯,问题是当我按下菜单键时,组中的第二个活动没有显示菜单.第一个活动可以正常显示菜单.
Well, the problem is that the second activity in the group doesn't show the menu when I press the menu Key. The first activity works fine showing the menu.
对这个问题有什么想法吗?
Any idea about this issue?
我在子活动中有此代码:
I have this code in child activity:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
menu.add(0, MENU_REFRESH, 0, R.string.menu_refresh).setIcon(R.drawable.ic_menu_refresh);
return result;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_REFRESH:
Log.d(TAG,"REFRESH");
refresh();
return true;
}
return super.onOptionsItemSelected(item);
}
推荐答案
检查 此 主题.
菜单可以在父级处理aactivity,但在孩子中创建活动
Menu's can be handled in the parent aactivity, but created in the child activity
这篇关于Android ActivityGroup 菜单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!