Custom Overflow Menu Outside of ActionBar - android

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).

Related

android overflow menu item is unable to display both icon and title

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.

Android Actionbar PopupMenu with Custom Item Layouts

I am working on an Android application where I have to design a menu which will populate from the action bar, like this:
I have tried my best but was not able to produce it using the Android controls.
The solutions I have tried are:
With Actionbar, add a menu item with a group with selectable="all", that produces the layout I need but when I click a checkbox for selecting it, the whole menu hides and selection is not done, moreover the menu icon in actionbar does not have the bottom right white arrow.
Tried creating a custom ActionProvider and added the menu items using class's OnPrepareSubMenu method but had the same issue.
I just need a push in the right direction and I can do the rest, suggestions are more than welcome.
Thank you :)
Use popupWindow.
In that you can make any custom layout and set it as content of your popupwindow and also you can specify an ANCHOR in your case it would be
R.id.your_menu_item
set a listener and listen the changes.

How to make a actionbar drop-down-menu that shows items horizontally?

I want to make a action-bar drop-down-menu that shows items (icons) horizontally. Like this:
This is suppose to be a action-bar withe drop-down menu, where you can choose a color.
So it should show the icons (colors) horizontally and the icons should be clickable. Until now I have only managed to make a vertical list.
If possible I would like to do this in XML.
The ActionBar is not designed for such a use-case. The ActionBar buttons are meant to replace the old options menu that could be triggered with a separate hardware button on older devices (pre HC/ICS). The overflow button (the one with the 3 dots) that you've drawn in your sketch is used when there isn't enough room to show all buttons (the Android framework takes care of this automatically), so those will be grouped in the overflow menu. Overriding this behavior is a bad idea (if even possible).
Instead you should consider another approach: Add one ActionButton to the ActionBar that is meant to handle the color chooser. When this button is clicked the best solution is to show an AlertDialog (you can easily insert your on Views here that show the colors you want) because this will work best even if the button is hidden in the overflow menu.
Alternatively you could trigger a PopupMenu or implement some QuickAction to handle the color chooser (this will probably suck if your button is hidden in the overflow menu and will also lead to a very confusing UI).

Android: Overflow icon event listener

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.

How to create a custom Pulldown in the Honeycomb ActionBar?

I would like to add a custom pulldown menu to the actionbar in my project similar to the one that can be found in the google books app (screen).
In this case it represents the complete table of contents of the book.
I tried to follow the guide from the developer site where there is an example with a SpinnerAdapter. But when i use a custom Layout (in my case a RelativeLayout with two TextViews in it) i get an Exception that saying "ArrayAdapter requires the resource ID to be a TextView". So i dismissed my idea with the pulldown but then i found the pulldown in the books app wich looks to me like they used a custom layout as well because it looks to me like two single TextViews in one Layout.
Could anybody please enlighten me if what i want to do is even possible and how?
To me, that looks like the options menu -- that's where options menu items not promoted to the action bar itself appear. Use onCreateOptionsMenu() and add whatever items you want to the Menu.
EDIT:
Sorry, the screenshot was a bit confusing. There are two possibilities that I can see:
This could be a submenu for that action bar item -- I haven't played with submenus and the action bar yet (though this reminds me that I need to do that...)
This could be a PopupMenu tied to a custom action bar View

Categories

Resources