当设备中没有任何默认菜单按钮时,不显示菜单按钮的任何迹象 [英] Not Showing Any Sign of Menu Button when there is not any default menu button in devices

查看:15
本文介绍了当设备中没有任何默认菜单按钮时,不显示菜单按钮的任何迹象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有 Settings 屏幕的应用程序,该屏幕在用户单击 OptionMenu 快捷方式时打开,该快捷方式在设备上显示为默认按钮或任何其他标志.

当设备中有默认菜单按钮时它工作正常,但当设备中没有任何默认菜单按钮时没有获得任何菜单选项的签名.

我的代码如下:

@Override公共布尔 onCreateOptionsMenu(菜单菜单){getMenuInflater().inflate(R.menu.menu_setting, menu);返回真;}@覆盖公共布尔 onOptionsItemSelected(MenuItem item) {开关(item.getItemId()){案例 R.id.btnSettingMenu:意图意图 = 新意图(MainActivity.this,注册Activity.class);intent.putExtra("From", "MainActivity");开始活动(意图);休息;默认:休息;}返回真;}

我已经参考了链接这里但无法解决我的问题.

我想补充的一点是:当我按下 PageUpF2 时,我在模拟器中获得菜单选项.>

但是当设备没有默认菜单按钮时,它不会以任何其他指示显示为三个点或其他方式.

我的问题:如果用户在像 Nexus 7 这样的真实设备中没有找到选项菜单,他如何进入我的设置屏幕?

提前致谢.

解决方案

用于在4.0以上设备中显示Menu图标:

如果你已经声明了 android:targetSdkVersion="xx"

如果不需要,请删除它.

如果你想声明它,那么在14

下面设置值0f xx

即android:targetSdkVersion="13".

希望它对你有用.

I am Working on One Application which has Settings Screen which Opens When User Click on OptionMenu Shortcut which shows on Devices as Default Button or any other Sign.

it Works fine when there is default menu button in device but not getting any Sign for Menu Option when there is not any default menu button in devices.

My Code is as Below:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_setting, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.btnSettingMenu:
        Intent intent = new Intent(MainActivity.this,
                RegisterActivity.class);
        intent.putExtra("From", "MainActivity");
        startActivity(intent);
        break;

    default:
        break;
    }

    return true;
}

I have refered to Link HERE but could not able to solve my problem.

Point I would like to add is: I am getting the Menu Option in Emulator when i am pressing PageUp or F2.

But when the Device Does not have Default Menu Button it is not Showing with any other indication as three dots or some other way.

My Question : How can User Go to my Setting Screen if he is not Finding Option Menu Sign in real devices Like Nexus 7?

Thanks in Advance.

解决方案

For showing Menu icon in above 4.0 Devices:

if you have declared android:targetSdkVersion="xx"

Either remove it if you don't required.

OR

If you want to declare it,then set value 0f xx below 14

i.e.android:targetSdkVersion="13".

Hope it will work for you.

这篇关于当设备中没有任何默认菜单按钮时,不显示菜单按钮的任何迹象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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