i was wondering if anyone could tell me how to choose which menu items go in to the actiobar and which ones go into the overflow menu, i have five menu items and the ones i want in the actionbar go in the overflow and the one i want in the overflow are in the actiobar.
How can i rearrange the actionbars?
Any help will be appreciated
There are two things you can do.
First you can set the flag
android:showAsAction="ifRoom"
This will show items if there is room, if not they will be placed in the overflow menu.
Second, the XML file is scanned linearly. So just put your actions that you in the overflow menu to the bottom.
The documentation states
Menu items that are not promoted to an action item are available in the overflow menu, revealed by
either the device Menu button (when available) or by an "overflow menu" button in the action bar
(when the device does not include a Menu button).
Here is also an good post with more information.
How to force overflow menu on android actionbar compat?
Related
Per usual my ActionBar has a number of menu items that I set as app:showAsAction="never". So when user clicks on the overflow button, these items show up but they don't have icons. How do I force the icons to show? The answer at Is it possible to display icons in a PopupMenu? does not answer my question as it is concerned with the popup menu. When I tried to apply it to my case it shows all items not just the ones in the overflow. Also I am anchoring it in the toolbar as I don't know how to get the overflow view.
I don't think there is a simple way to toggle showing an icon in the action bar overflow menu. But I did find that someone was able to create a fully customized overflow menu:
http://keepsafe.github.io/2014/11/19/building-a-custom-overflow-menu.html
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.
First of, I'm using SherlockActionBar.
I've one MenuItem that is 'always' showed in the ActionBar and one other MenuItem that is only showed 'ifRoom'. There are also other MenuItems that are 'never' showed in the ActionBar and therefore there exists a Overflow Icon (if device has no hardwarebutton).
My question now is, how am I able to tell if the MenuItem with 'ifRoom' is currently showed or not in the ActionBar (in ActionBar or Overflow?)? I need to know that because I'm using the ShowcaseView Library to highlight these options. Therefore I have to know if I should highlight the Overflow or I can directly target to the MenuItem.
Thx
Imo there is no way to know if a menu entry is on the overflow menu via an API.
Even with "never" you can still be pushed into the overflow menu when the the title is long and your device is very narrow.
What you could try is to place an action view into your menu items and get its position on screen. If not on screen you can be certain it is pushed into the overflow menu.
I'm using ActionBarSherlock and I wonder if it is possible to have a popup menu at the bottom of the screen additionally? I'd like this menu to appear when the user clicks the default menu button (hardware for older mobiles).
How can I do this?
The actionbar menu overflow is automatically replaced by items in "menu" popup if you have a hardware menu button.
http://developer.android.com/design/patterns/compatibility.html
In order for items to appear in there you should set
android:showAsAction="never"
to your menu items
You must take a look at the How to Create Android Menus?
I hope this will help you.
Does anyone know how to add a listener to the action overflow menu button ( the three dots on the action bar )?
I would like to add elements dynamically to the overflow menu, and I can't figure out how to do it.
Help please :)
Does anyone know how to add a listener to the action overflow menu button
You don't.
I would like to add elements dynamically to the overflow menu
You can try invalidateOptionsMenu() at the point when you know that you want different menu choices than what you had set up previously. However, I have heard reports that this may not affect the action bar.
If the "dynamic" aspect is based on fragments coming and going, have your fragments implement the option menu items (via overriding onCreateOptionsMenu() and calling setHasOptionsMenu(true)). Android will add and remove items based on the changing mix of fragments on the screen.