I'm trying to get the overflow button from the action bar to show up in the bottom, next to the back/home/other-apps buttons. I was assuming this would be the case if I turn off the title bar, but it doesn't. I tried googling it, but I can't find any solutions.
Who can give me a hint?
For example this app has it:
In your AndroidManifest you have to set the targetSdkVersion to 13 or earlier like this:
<uses-sdk android:targetSdkVersion="13" />
That will force ICS to run your app in compatibility mode and give you the 3 dots in your bottom bar for your overflow menu.
Adding the overflow menu button to the system navigation bar is done to support apps targeting older version of android (2.3 and older) that don't have a hardware Menu button.
http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html
The article above provides the logic when the system places the overflow button in the nav bar. It doesn't say how to force it to appear though for all devices. but it may help.
Did you try this code for creating option menu?
//Menu options within the app.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
Related
I'm currently developing an android application, whose target is API19 (min sdk version is set to API14). This app will not run in a mobile phone, but on a custom device.
The screen is not a touch screen, so user interaction will rely on a keyboard, and also I have to mention that this app won't have action bar implemented (I'm currently hidding it).
I'm trying to implement the old style menu behaviour, where you could bring up the menu by pressing the menu button on your device (deprecated since API10), like this:
So, things get complicated when I try to inflate the menu, as android will automatically inflate my menu in the action bar (since API11):
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
QUESTION:
I know it's deprecated, but still I want to implement the menu that way, therefore, is there any way I can force android to inflate this menu "the old way", without lowering my target API ?
I have searched for Option menu and overflow Action menu, but did not get any difference in both.
Is there any difference or both are exactly same?
The option menu is used on Android 1.x/2.x devices, for apps that are not using an action bar backport (e.g., appcompat-v7).
The overflow menu in the action bar is used on Android devices that have an action bar, either the native action bar or a backport.
Menu items, such as those defined in onCreateOptionsMenu(), will go into an options menu on devices and apps that use it, or will go into the action bar on devices and apps that use one of those. Menu items not specifically designated to go into the action bar as toolbar-style buttons or other widgets will go into the overflow. Menu items that do not fit in the action bar will also go into the overflow.
Android uses the old options menu terms (e.g., onCreateOptionsMenu() instead of onCreateActionBarItems()) for backwards compatibility, so apps can be written to use the native action bar and still work, to some extent, on devices that lack an action bar.
There only exists one options menu. If the device has a menu key, then the overflow menu items appear when the key is pressed. On the other side, if the device has not menu key, then they appear on the action bar overflow icon.
recently I've switched from the regular action bar implementation to the recently released appcompat implementation. My app made heavy use of the action bar to provide functionality. Since switching, on older spots
APIs (less than 11) don't have any menu items. And newer APIs do, but they don't show the image like configured (if room|withText). Has anyone else experienced this or came up with any solutions?
I found out what was up, when using the appcompat library. You can create your menu just like normal.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
But, in your menu xml files, add a xmlns:app attribute to the menu tag, like so:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
then, in each of your menu items, where you usually specify the "showAs" style (ifRoom, withText, etc.), include this alternative line alongside the regular one:
app:showAsAction="ifRoom|withText"
android:showAsAction="ifRoom|withText"
After this, your menus will show correctly on both current and old APIs. I got this information from here.
If there is a physical "Menu" button on device, it will show the contextual menu. If not, the menu item will be added to the ActionBar.
I am new to android.
How can i create option menu with out images like in the attached image? Do i need to use action bar or normal onCreateOptionMenu will do?
If you've developed your application for Android 3.0 (API level 11)
and higher, items from the options menu are available in the action
bar. By default, the system places all items in the action overflow,
which the user can reveal with the action overflow icon on the right
side of the action bar (or by pressing the device Menu button, if
available). To enable quick access to important actions, you can
promote a few items to appear in the action bar by adding
android:showAsAction="ifRoom" to the corresponding elements.
You can refer this doc for more detail.
in my app the android default menu button is not visible? why? Any help?
Refer this:
On Android Honeycomb how do I add option menu to the home bar at the bottom of the screen?
And this:
onCreate Options menu is not showing in android 3.1
You can simple edit target SDK in manifest file to force use SDK of mobile rather than tablet like this:
android:targetSdkVersion="10"
Not only should your apps stop relying on the hardware Menu button, but you should stop thinking about your activities using a “menu button” at all.Your activities should provide buttons for important user actions directly in the action bar (or elsewhere on screen). Those that can’t fit in the action bar end up in the action overflow.
In order to provide the most intuitive and consistent user experience in your apps, you should migrate your designs away from using the Menu button and toward using the action bar.
Ice Cream Sandwich rolls out to more devices, it’s important that you begin to migrate your designs to the action bar in order to promote a consistent Android user experience.See this link
Did you hook up a xml menu file to your activity ?
#Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
getMenuInflater().inflate(R.menu.xmlfilename, (android.view.Menu) menu);
return true;
}