安卓的ActivityGroup菜单问题 [英] Android ActivityGroup Menu Problem

查看:181
本文介绍了安卓的ActivityGroup菜单问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用一个问题的ActivityGroup 。我有内部的两项活动的ActivityGroup 和他们都使用菜单(覆盖onCreateOptionMenu和onOptionsItemSelected)。

好了,问题是,该组中的第二个活动不显示菜单时我preSS菜单键。第一项活动工作正常显示菜单。

有关此问题的任何想法?

我有这个code的子活动:

  @覆盖
公共布尔onCreateOptionsMenu(功能菜单){
    布尔结果= super.onCreateOptionsMenu(菜单);
    menu.add(0,MENU_REFRESH,0,R.string.menu_refresh).setIcon(R.drawable.ic_menu_refresh);
    返回结果;
}

@覆盖
公共布尔onOptionsItemSelected(菜单项项){
    开关(item.getItemId()){
    案例MENU_REFRESH:
        Log.d(TAG,REFRESH);
        刷新();
        返回true;
    }
    返回super.onOptionsItemSelected(项目);
}
 

解决方案

检查的这个线程。

  

菜单的可以在父处理   aactivity,但在儿童中创建   活动

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);
}

解决方案

Check this thread.

Menu's can be handled in the parent aactivity, but created in the child activity

这篇关于安卓的ActivityGroup菜单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆