[否键盘ID 0 QUOT ;? [英] "No keyboard for id 0"?

查看:139
本文介绍了[否键盘ID 0 QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用程序新。发展,我现在已经遇到了菜单按钮一个奇怪的问题。这里是东西:

I am new in Android app. development, now I have encountered a strange problem with the Menu button. Here is the thing:

我有两个活动,ActivityOne和ActivityTwo,其中ActivityTwo是ActivityOne孩子的活动。在这两个活动中,我已经定义菜单按钮选项,如以下内容:

I have two activities, "ActivityOne" and "ActivityTwo", where "ActivityTwo" is the child Activity of "ActivityOne". In both activity, I have defined the menu button options like following:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuItem insertMenuItem = menu.add(0, INSERT_ID, 0, R.string.menu_insert);
    insertMenuItem.setIcon(R.drawable.ic_menu_add);

    MenuItem settingMenuItem = menu.add(0, SETTING_ID, 0, R.string.menu_setting);
    settingMenuItem.setIcon(R.drawable.ic_menu_settings);

    MenuItem aboutMenuItem = menu.add(0, ABOUT_ID, 0, R.string.menu_about);
    aboutMenuItem.setIcon(R.drawable.ic_menu_about);

    logPrinter.println("creating menu options...");

    return true;
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch(item.getItemId()) {
        case INSERT_ID:
            doInsert();
            return true;
        case SETTING_ID:
         return true;
        case ABOUT_ID:
         showAbout();
         return true;
    }

    return super.onMenuItemSelected(featureId, item);
}

在ActivityOne,当我点击的选单按钮,没有菜单选项从屏幕底部弹出,当我检查了LogCat中控制台,有两个警告的消息,这是 否键盘ID 0 使用默认的键盘对应:/system/usr/keychars/qwerty.kcm.bin

In "ActivityOne", when I click the physical Menu button, there is no menu options pop up from screen bottom, when I checked the LogCat console, there are two warning messages, which are "No keyboard for id 0" and "Using default keyMap:/system/usr/keychars/qwerty.kcm.bin" .

但是,ActivityTwo,菜单按钮做工精细,它显示了我,我中定义的菜单选项。

BUT, in "ActivityTwo", the menu button works fine, it shows me those menu options I defined.

为什么菜单按钮不会在ActivityOne工作吗?什么是警告的意思味精???

Why the menu button does not work in "ActivityOne" ?? What does the warning msg mean???

推荐答案

无键盘ID 0并不意味着任何东西。

The "no keyboard for id 0" doesn't mean anything.

现在,有你的两个活动的定义 onCreateOptionsMenu ?如果不是,这样做。

Now, have you defined onCreateOptionsMenu in both activities? If not, do it.

此外,使用<一个href=\"http://d.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)\"相对=nofollow> onOptionsItemSelected 而不是 onMenuItemSelected

这篇关于[否键盘ID 0 QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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