I have 8 menu items. I am using menu.add() method to create all 8 menu items. Now when i run the app. The menu is shown in two rows with last item of second row being more and then clicking more a single list of the remaining 3 items is shown. I want all the 8 menu items to be shown in the single list without more button and rows. How can i achieve this functionality. Any help is appreciated in advance.
Thanks
According to android docs
On Android 3.0 and higher, items from the options menu are presented by the action bar as a combination of on-screen action items and overflow options. Beginning with Android 3.0, the Menu button is deprecated (some devices don't have one), so you should migrate toward using the action bar to provide access to actions and other options.
I suggest to use Action bar or Implement Sherlock library to have a vertical list of menu in your project.
Related
The number of option menu items can change on runtime in my app, depending on the actions of the user.
I am using this right now for my menu items :
app:showAsAction="ifRoom"
If there is enough room in some cases there are 4 menu items visible in the actionbar. Is there a way to limit the visible menu items?
In my case, I want maximum 2 menu items visible in the actionbar, the additional entries should be in the "more" section.
You can force maximum two visible MenuItem as action buttons on the actionbar by setting:
app:showAsAction="never"
for all the menu items, except the first two.
As mentioned in the Android docs:
never : Never place this item in the app bar. Instead, list the item in the app bar's overflow menu.
Currently you're using ifRoom keyword, which will show the menu item in the action bar if there's enough space available for it. So, you won't be able to force max two items using this. From docs:
ifRoom : Only place this item in the app bar if there is room for it. If there is not room for all the items marked "ifRoom", the items with the lowest orderInCategory values are displayed as actions, and the remaining items are displayed in the overflow menu.
P.S. : What you're calling more section is referred as overflow menu in the above text and in Android.
How create menu
https://www.google.com/design/spec/components/menus.html#menus-usage
The is PopupMenu or Spinnet?
The menu shown with the contacts is simply an Options menu as defined in the SDK.
Android will automatically position and manage your menu provided that you populate it in the activity.
If you've developed your application for Android 3.0 (API level 11) and higher, items from the options menu are available in the app 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 app 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 app bar by adding android:showAsAction="ifRoom" to the corresponding <item> elements (see figure 2).
To add to a menu, see Activity.onCreateOptionsMenu
I am developing my first android app. I would like to add a dropdown menu to action bar. I used the second option described in this question, but I am not able to set the onItemSelectedListner. I am using the tab navigation, so I can't set the navigation to listview. How can I get this to work?
I need to implement a custom overflow menu with menu items and the overflow icon if the screen size cannot show all the icons. I cannot use a side scroll since I am already inside an expanded list view. I cannot use the Top or bottom action bar menu because the action will change based on what list item has been expanded.
So I would like to create my own overflow menu - similar to the gmail screenshots attached
Any ideas? Apparently ABS can be used for this but I can't figure it out, please help :)
ListPopupWindow is what you're looking for. It's an API 11+ class, however. ABS includes a backported version which is basically just a ListView inside a PopupWindow (both API 1 classes).
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.