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