I disable/enable an action item (represented with an icon, not in the overflow menu) on the Action Bar based on if the action is allowed or not. I would like to add a Toast when the user taps on the disabled action item icon to inform why this is disabled. Is it possible to detect a tap on a disabled item in the action bar??
Thanks
No, because it is disabled. Your alternative is to leave the action item enabled, but change icons instead of enable/disable, so you get control in all cases. This is not the best from an accessibility standpoint (those who cannot see your icon will not necessarily realize that it is "disabled").
Related
I'm looking to show the action bar "action mode" persistently throughout the life on an activity. This activity edits an image and once the user clicks the check mark the image is saved and the activity exits. However, if they press back the edit process is canceled.
My action bar is translucent with overlay content set to true. Here is how it looks.
Here is what I have tried
1. Action bar is translucent as well as my action mode. Action mode is overlayed causing a darkening of the action bar.
2. Make action bar transparent. Everything looks good but once you click the check mark you see an odd looking action bar without a background which is shown for a second.
3. Hide the action bar. This causes animation issues where you can see the action bar animate in while the activity is exiting.
All these attempts are hacks and they don't work well. Maybe I can somehow add the check mark on the left? I'm not sure how to reproduce that action mode as my action bar. Hopefully someone has a good idea on how I can achieve the action mode style.
When you put a lot of action items on the action bar, some of them get to be inserted into the overflow menu, or become available by clicking on the menu button (if present).
Is there a way to be notified when this occurs? Maybe even know which items got to be into the overflow menu (or available via the menu button) ?
Again, I don't ask how to put items there and I don't need to get explanation about how to define action items. I ask how to know when and which items get to be there.
You cannot decide which item to be into Action overflow menu but you can decide which to be shown always on Action bar.
You can also use "always" to declare that an item always appear as
an action button. However, you should not force an item to appear in
the action bar this way. Doing so can create layout problems on
devices with a narrow screen. It's best to instead use "ifRoom" to
request that an item appear in the action bar, but allow the system to
move it into the overflow when there's not enough room. However, it
might be necessary to use this value if the item includes an action
view that cannot be collapsed and must always be visible to provide
access to a critical feature.
http://developer.android.com/guide/topics/ui/actionbar.html
I'm developing an android app which doesn't have an action bar. I have the sign out and sync options as menu items. When I tried this in my Nexus 5, the menu button is nowhere to be found. It usually appears in the action bar. Is there a way to keep the menu button and hide the action bar at the same time?
Is there a way to keep the menu button and hide the action bar at the same time?
No. If you are not going to use the action bar, you cannot reliably use <menu> resources. Please put "sign out and sync options" in your own GUI, such as via buttons.
Note that the MENU key is itself deprecated now; few devices going forward will have one.
I'm having action bar which display application Name, search and more action menu item, though i'm using sherlock library for that. I want to disable the toast of search and more item when i performing long press event in the action bar. Did anyone knows how to disable / redefine long press event.
This is a feature of the native action bar. It cannot be removed.
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.