0

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

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

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" .

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

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

Mellon
  • 37,586
  • 78
  • 186
  • 264

1 Answers1

0

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

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

Also, use onOptionsItemSelected instead of onMenuItemSelected.

Felix
  • 88,392
  • 43
  • 149
  • 167
  • Hi, YES, I have defined onCreateOptionsMenu in both activities. I will use onMenuItemSelected and see if this helps. I will let you know tomorrow. Thanks. – Mellon Oct 14 '10 at 16:31
  • Hi, I have used onOptionsItemSelected instead of onMenuItemSelected, but it does not help, I still can not have my Menu options pop up when I clicke the physical Menu button... :( Any other suggestions are appreciated. – Mellon Oct 15 '10 at 07:40