0

I want to build in my application an ActionBar with a button that makes the role of the old hardware menu button. I'm working on 4.0.3 platform with min sdk=8. The problem is i don't have the menu button in ActionBar and always have to press on emulator menu button to show it. Don't know what to do, there is surely a trick.

Menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
   <item
        android:id="@+id/menu_settings"
        android:icon="@drawable/ic_action_settings"
       android:showAsAction="always"
        android:title="@string/menu_settings"/>
   <item android:id="@+id/menu_help"
        android:title="Help">
   </item>
</menu>

And prepare the menu in Java code like always:

 public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return super.onCreateOptionsMenu(menu);
    }

I want a button in Actionbar that shows that menu. Possible?

crusy
  • 1,424
  • 2
  • 25
  • 54
androniennn
  • 3,117
  • 11
  • 50
  • 107

1 Answers1

1

The problem is i don't have the menu button in ActionBar and always have to press on emulator menu button to show it. Don't know what to do, there is surely a trick.

Not really.

The overflow menu affordance will only appear in the action bar on devices that lack an off-screen MENU button. This will be true for most tablets and many phones that originally shipped with Android 4.0 or higher.

For devices that do have a dedicated MENU button, that is used to bring up the overflow menu.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So that's completely normal that the there is no software menu button in the app. But can i make a custom button to make the role of menu button? Please see the image in my post. – androniennn Sep 28 '12 at 16:28
  • @androniennn: You can put whatever action bar items you want in your action bar, but they will not display the overflow menu. The users of your app, on devices that have a MENU button, will be used to pressing the MENU button to get to the overflow menu. Either follow the platform's policies regarding the overflow menu, or do not use the overflow menu. – CommonsWare Sep 28 '12 at 16:36
  • Clear boss ;). Thank you. I now have all informations more clear :). – androniennn Sep 28 '12 at 16:44