My Android app (Api level 12, Android 3.1) has an activity with many menu items. Some items are on the action bar (showAsAction="always") while other ones are normal menu items (showAsAction="never") including a submenu: normal menu items have never to be displayed on the action bar, yet they are more than 6 in number so the "more" button also appears when I tap the menu button.
I tested the app on various virtual devices in the emulator and I see that the menu is correctly displayed on all devices except the smartphone (Android 3.1) where I get the action bar items and, if I tap the menu button, some of the normal items displayed along with the "more" button; but when I tap the "more" button nothing happens and the further menu items are not displayed.
Is this an issue of the emulator or my app will behave similarly on real smartphone devices?
Use this instead,
android:showAsAction="ifRoom|withText"
android:orderInCategory="1"
Lower the orderInCategory value, the first the menu item will be displayed.
Related
If you've developed your application for Android 2.3.x (API level 10) or lower, the contents of your options menu appear at the bottom of the screen when the user presses the Menu button, as shown in figure 1. When opened, the first visible portion is the icon menu, which holds up to six menu items. If your menu includes more than six items, Android places the sixth item and the rest into the overflow menu, which the user can open by selecting More.
So adding a dynamic toolbar from appcompat-v7 will not dismiss the use of the menu button on the older phones?
The Action configuration behavior seems different between an iPhone and Android device.
On an iOS device, the action items or buttons are permanently visible on a toolbar. On the Android the user has to select menu on their device first to make these action items visible in a list. The list will popup.
Is there are way to make these action items always visible on the Android, just like on the iPhone? Our customer base will for sure not know to press that button in order to see more options for our app.
On the Android the user has to select menu on their device first to make these action items visible in a list
It depends on the phone. This behavior is right only for the phones that have a menu button (like the Samsung ones). For the phones without a menu bouton (like the nexus 5 for example), menu can be visible after clicking on the "3 points" in the action bar (the number 3 is the following photo) :
Is there are way to make these action items always visible on the Android, just like on the iPhone?
Yes ! If you see the number 2 into the previous photo, you can see that 2 icons are always visible (the glass and the google play store icon). These 2 icons are 2 menu items but setting as "show always".
More information can be found here.
I have an application which runs full-screen and relies on the menu button. What I didn't realise is that devices like the Galaxy Tab use an actionbar which no longer has a menu button. My app currently loads a fragment displaying a settings menu when one touches the menu button:
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
FragmentManager lFM = getSupportFragmentManager();
SettingsDialogFragment lSettingsDialog = new SettingsDialogFragment();
lSettingsDialog.show(lFM, "Settings");
return false;
}
I understand it is possible to add a custom icon to the action bar which when pressed could result in the same behaviour as a menu button. What I am unsure about is how to implement this.
How do I know that a device doesn't have a menu button and I need to add an icon to the action bar? It can't be as easy as checking the SDK version as apparently the actionbar was introduced in honeycomb, but my Galaxy Note runs ice cream sandwich and doesn't have an action bar (it still has a menu button). I don't want to give up any real-estate so adding buttons or menu options to my main layout isn't an option.
I just read on google developer that:
Navigation Bar New for phones in Android 4.0, the navigation bar is
present only on devices that don't have the traditional hardware keys.
It houses the device navigation controls Back, Home, and Recents, and
also displays a menu for apps written for Android 2.3 or earlier.
So I tried setting the target version on my app to 8. Instead of a menu I get a button allowing me to change the screen size of my app - but no menu button.
I have an application which runs full-screen and relies on the menu button.
That has been a bad idea for two years.
What I didn't realise is that devices like the Galaxy Tab use an actionbar which no longer has a menu button.
Such devices have been around for two years.
My app currently loads a fragment displaying a settings menu when one touches the menu button
That was never an appropriate design move. Please allow the MENU button, where it exists, to behave normally, displaying an options menu on Android 1.x/2.x and triggering the action bar overflow on Android 3.0+.
How do I know that a device doesn't have a menu button
http://developer.android.com/reference/android/view/ViewConfiguration.html#hasPermanentMenuKey()
I have an application running correctly in all the devices with a physical menu button. Few days before I installed that app in a HTC One (Android 4) and the menu just disappeared from my app. On other apps that have a menu add the 3 points menu indicator in action bar.
I don't want to put here the code, because it is nothing special... just a simple menu, added inside onCreateOptionsMenu method. What should I do to fix this issue for HTC One?
The menu appears on other devices running Android 4 (like Galaxy s3) with physical menu button.
Few days before I installed that app in a HTC One (Android 4) and the menu just disappeared from my app. On other apps that have a menu add the 3 points menu indicator in action bar.
Devices with an off-screen MENU button usually will not have the "3 points menu indicator in the action bar". Users access the overflow by pressing that MENU button.
For example, this sample app has an overflow. When running on a device or emulator with an off-screen MENU button, there is no "3 points menu indicator in the action bar":
What should I do to fix this issue for HTC One?
Well, my HTC One S does not have MENU button. Presumably you have some other version of the HTC One series that does have a MENU button. If so, you can press the MENU button:
The menu appears on other devices running Android 4 (like Galaxy s3) with physical menu button.
That was the decision of those device manufacturers, then, for those specific devics.
For the record, here is the app on a Galaxy Nexus (no off-screen MENU button):
Here is the app on an HTC One S (no off-screen MENU button, illustrating a bug where the overflow is shown in the action bar and in a nav bar):
Here is the app with the fix applied, on that HTC One S:
Here is the app on a Nexus S (with an off-screen MENU button):
Here is the app on a Galaxy Note II (with an off-screen MENU button):
As you can see, in many cases, the existence of an off-screen MENU button suppresses the "3 points menu indicator in the action bar".
I was reading this article, and was surprised to read that:
You might notice only 2 of the 3 original menu items are displayed in
the new action bar [...]. To get the other menu items, you must go to
the "overflow menu".
The reason why I'm surprised is that when I do the same thing using an emulated Nexus (ie: no menu button) running on Android 4.1.2, then the overflow button does not appear in the menu, but directly in the action bar.
Any idea why the behavior is different ?
Note: in my AndroidManifest.xml, I'm using minSdkVersion="11"
The button which appears in the naviagation bar for devices which lack physical buttons isn't the overflow button; it's the legacy menu button. The behavior you are seeing is the correct, expected behavior.