I am trying to set image in overflow menu items like as in flipkart.But I am unable to set image.Can anybody provide me code snippet for doing this
If you are trying on Android 3.0+, it won't show icons in the menu items. Google has removed them in order to make the menu look similar on different apps. See icon in menu not showing in android and on Android Developers blog.
It is not possible to add icons in overflow menu item as per googles new change, If u still want, try this.
for device with overflow hardware button:
override hardware button click and show a transparent fragment with list view as like over flow menu in samsung devices(S3, s4) with icon.
for devices without hardware button:
use sub menu to look as menu. google still supports icon in sub menu.
That's how it's supposed to work.
If the icon shows in the action bar, it will only show the icon (with an optional title by using android:showAsAction="always|withText" or android:showAsAction="ifRoom|withText").
If the icon does not show in the action bar, it will only show in the overflow menu as text. Note that there is no "withIcon" enum value for the android:showAsAction attribute.
Related
I have created options menu it has some attributes like android:I'd, android : title,android:icon etc how can I set a image as android option menu and also I want title of the item below the icon not beside the icon
You cannot do this easily and you should not. What you explain sounds more like Tabs to me, which you could use instead. With these you'll get text below the icon out of the box.
I need to open android support library action bar overflow menu (the one shown with three vertical dots) programatically. I know its a silly requirement but one of my client is insisting that they want the menu option to be opened and visible when user tap on a button in an activity.
Any pointer on how to do this will be highly appreciated.
Try using openOptionsMenu in your Activity.
You can do something similar to this implementing your own custom ActionProvider Check this out, in the "Creating a custom action provider" section.
Hope it helps
Using Action Bar Compat support library, I have noticed that the settings menu (3 dots) does not show the icons with each item. The xml is correctly configured (android:icon="#drawable/ic_item") but the problem occurs running my app with emulator (v2.2) and real device (v2.2).
The contextual menu only displays the text items without their icons.
However, if I run the app in a real device with v4.0+, the icons are shown correctly with the text items of the contextual menu.
Any idea to solve it?
Thanks.
Overflow menu does not have icons by design by Google. This is the proper (or at least standard) way for it to behave.
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 developing on a Galaxy Nexus, and I would like the settings icon on the main dock to open up some window of buttons. How do I go about handling this button press? it's that button that looks like a vertical "..."
That button:
will only appear on devices without a MENU button
will only appear if you have action bar items in the overflow menu
cannot be directly used for other purposes
You are welcome to have an action item in the action bar that will "open up some window of buttons". You can choose whatever icon you want for this action item. I strongly encourage you to not use the same icon as the action overflow menu. There are millions of possible icons, so surely you can choose one of greater relevance to whatever the "window of buttons" is and will not conflict with the users' expectations of what the action bar overflow should look and work like.