Honeycomb Drop-down options menu. How to show? - android

How to create Drop-down options menu for Action Menu items for HoneyComb?
I have 5 Action Menu items and I want add dropdown to menu_feed_share(share button):
menu.xml
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/menu_feed_share" android:showAsAction="ifRoom"
android:icon="#drawable/icon_share" />
<item android:id="#+id/menu_feed_browser" android:showAsAction="ifRoom"
android:icon="#drawable/icon_web" />
<item android:id="#+id/menu_feed_bookmark" android:showAsAction="ifRoom"
android:icon="#drawable/icon_bookmark" />
<item android:id="#+id/menu_feed_search" android:showAsAction="ifRoom"
android:icon="#drawable/icon_search" android:actionViewClass="android.widget.SearchView" />
<item android:id="#+id/menu_feed_settings" android:showAsAction="ifRoom"
android:icon="#drawable/icon_preferences" />
</menu>
I created SpinnerAdapter and listener, but I do not know how to show dropdown, how to assign dropdown to button share..
SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.share_list, android.R.layout.simple_spinner_dropdown_item);
actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
Can anybody help me?
Thanks!
upd..
I want like something(here is menu. I need the same for Share-betton):

So, it's simple:
Thanks all!
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/menu_feed_share" android:showAsAction="ifRoom"
android:icon="#drawable/icon_share">
<menu>
<group
android:id="#+id/menu_nav_group">
<item
android:id="#+id/fb_menu"
android:title="Facebook"/>
<item
android:id="#+id/twitter_menu"
android:title="Twitter"/>
<item
android:id="#+id/mail_menu"
android:title="Mail"/>
</group>
</menu>
</item>
<item android:id="#+id/menu_feed_browser" android:showAsAction="ifRoom"
android:icon="#drawable/icon_web" />
<item android:id="#+id/menu_feed_bookmark" android:showAsAction="ifRoom"
android:icon="#drawable/icon_bookmark" />
<item android:id="#+id/menu_feed_search" android:showAsAction="ifRoom"
android:icon="#drawable/icon_search" android:actionViewClass="android.widget.SearchView" />
<item android:id="#+id/menu_feed_settings" android:showAsAction="ifRoom"
android:icon="#drawable/icon_preferences" />
</menu>

This is not an "Actions Menu" but an "Options Menu" see: http://developer.android.com/guide/topics/ui/menus.html for more information on menus in Android.
use: onCreateOptionsMenu and onOptionsItemSelected to make this work. I belive that the dropdown menus like your picture shows are only seen in Honeycomb tablets. Other phone android OS will have these menu options show on the bottom of the screen as seen in the link above. Hope this answers your question.

How to create Drop-down Navigation for Action Menu items for HoneyComb?
You don't, any more than you create "Drop-down Navigation for Action Menu items" in other versions of Android. Android has never supported "Drop-down Navigation for Action Menu items". There isn't even a concept in Android of "Action Menu" -- I am guessing that you mean "options menu".
There is "list mode" for an action bar, which displays a Spinner, but that is not associated with an options menu item.

Related

Android navigation app change the icon of listed menus

I have use this code for menu icon but does not displayed in app why?
Please help me to to display icon left side of navigation menu list
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/income"
android:icon="#drawable/ic_income"
android:title="Income" />
<item
android:id="#+id/expense"
android:icon="#drawable/ic_expense"
android:title="Expense" />
<item
android:id="#+id/nav_settings"
android:icon="#drawable/ic_setting"
android:title="#string/nav_settings" />
</group>
</menu>
We have to set icon list as null then only it display the icon in navigation menu list
For that use following this code
navigationView.setItemIconTintList(null);

How to hide action bar on clicking search menu item and display when search is done?

I've an action bar and three tabs each includes some list to display.
When I click search I want the rest of the action bar should be hidden except the list in a tab and search item it self should be enabled, where want to search.
How can I achieve it?
Edit:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Single menu item
Set id, icon and Title for each menu item
-->
<item
android:id="#+id/action_search"
android:title="#string/action_search"
android:orderInCategory="100"
android:icon="#drawable/ic_action_search"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView"/>
<item android:id="#+id/home"
android:icon="#drawable/icon_home"
android:title="Home" />
<item android:id="#+id/totalCash"
android:icon="#drawable/icon_delivered"
android:title="Cod" />
<item android:id="#+id/statusForEach"
android:icon="#drawable/icon_cancelled"
android:title="Status" />
<item android:id="#+id/logout4"
android:icon="#drawable/icon_cancelled"
android:title="Logout" />
<!--<item android:id="#+id/menu_delete"
android:icon="#drawable/icon_delete"
android:title="Delete" />
<item android:id="#+id/menu_preferences"
android:icon="#drawable/icon_preferences"
android:title="Preferences" />-->
add below line to all menu items except search
app:showAsAction="ifRoom"
and in your search item add
app:iconifiedByDefault="true"
You have to implement MenuItemCompat interface to get those events. that will allow you to listen open and close and many more events. so check it.

How to move action bar icons to overflow icons automatically?

I know two ways to show action bar icons. My minimum sdk is 14 and target sdk 19. I am debugging with android 4.2.
First one
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/mPre"
android:icon="#drawable/ic_action_previous_item"
android:showAsAction="always"
android:title="Previous"/>
<item
android:id="#+id/mNext"
android:icon="#drawable/ic_action_next_item"
android:showAsAction="ifRoom"
android:title="Next"/>
<item
android:id="#+id/mShare"
android:icon="#drawable/ic_action_share"
android:showAsAction="ifRoom"
android:title="Share"/>
<item
android:id="#+id/mFb"
android:icon="#drawable/fb"
android:showAsAction="ifRoom"
android:title="Facebook"/>
<item
android:id="#+id/mhelp"
android:icon="#drawable/ic_action_help"
android:showAsAction="ifRoom"
android:title="Help"/>
</menu>
This will show icon dynamically (2 or 3 as consider space of action bar). But problem is, this is not showing extra menu in overflow icon. When I touch my phone menu bar, extra menu will appears, but I want extra menu in overflow icon.
For solution my second code.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/mPre"
android:icon="#drawable/ic_action_previous_item"
android:showAsAction="always"
android:title="Previous"/>
<item
android:id="#+id/mNext"
android:icon="#drawable/ic_action_next_item"
android:showAsAction="always"
android:title="Next"/>
<item
android:id="#+id/mMore"
android:icon="#drawable/ic_action_overflow"
android:showAsAction="always"
android:title="More">
<menu>
<item
android:id="#+id/mShare"
android:icon="#drawable/ic_action_share"
android:showAsAction="ifRoom"
android:title="Share"/>
<item
android:id="#+id/mFb"
android:icon="#drawable/fb"
android:showAsAction="never"
android:title="Facebook"/>
<item
android:id="#+id/mhelp"
android:icon="#drawable/ic_action_help"
android:showAsAction="never"
android:title="Help"/>
</menu>
</item>
</menu>
The problem of this code this is not really dynamic. I am showing here two icon always and put others icon in overflow icon, this overflow icon is not real overflow icon.
Now what I want?
I want if I have five menu as much as menu will show in action bar and rest of the icons are stored in overflow icon automatically.
I hope you guys get my problem. Please help me. Thanks in advance.
i think you need to use this
android:showAsAction="ifRoom|withText"
the parameter showAsAction decides where the icon is to be shown
refer to this link and the documentation
If I understand correctly, you want the the action bar icons to always show on the overflow? If that's the case, you can try the following:
<item
android:id="#+id/action_settings"
android:title="Test"
app:showAsAction="never" />

Menu Item in Action bar hide in small screen in android

I am using an actionbar with actionbar tab in an app. i have menu item and three tab with home icon in actionbar.
BUT When i run this app on emulator if menu item has property showAsAction with value "ifroom" then some of them are appear because of no more room
but the menu icon at the right upper corner is missing everytime i run this app.
Here is the image what is come in emulator :
and image below what i need :
here is my code for menu.xml:
<item android:id="#+id/menu_add" android:title="Add" android:icon="#drawable/icon" />
<item android:id="#+id/menu_DashBoard" android:title="DashBoard" />
<item android:id="#+id/menu_Master_Entry" android:title="Master Entry" />
<item android:id="#+id/menu_Product_Section" android:title="Product Section" />
<item android:id="#+id/menu_Retailers_Orders" android:title="Retailers Orders" />
<item android:id="#+id/action_search" android:icon="#drawable/search_icon"
android:title="Search" android:showAsAction="ifRoom" android:layout_gravity="left"/>
<item android:id="#+id/action_calender" android:title="Calender"
android:showAsAction="ifRoom" android:icon="#drawable/calender" android:layout_gravity="left" />
<item android:id="#+id/action_message" android:title="Message"
android:showAsAction="ifRoom" android:icon="#drawable/messageicon" android:layout_gravity="left"/>
Please help .. why it is come and what is the solution of this problem?
THANKS in advance. I only want that this menu dropdown at the last in actionbar should be shown in each screen size but it disappear in phone and shown on tab(10.1)
You can change android:showAsAction="ifRoom" to android:showAsAction="always"but this is not recommended.
If there is not enough room this items are added to more option at the end of the action bar where thr title of this item is shown in a drop-down (kind of) list.

Android Action bar Sherlock show actions items in dropdown always

I have set three action items which am adding to the ABS through menu XML like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/menu_share_app"
android:icon="#drawable/share_ab"
android:showAsAction="collapseActionView"
android:title="#string/menu_share_app"/>
<item
android:id="#+id/menu_search"
android:icon="#drawable/share_ab"
android:showAsAction="always"
android:title="#string/menu_search"/>
<item
android:id="#+id/menu_settings"
android:icon="#drawable/share_ab"
android:showAsAction="collapseActionView"
android:title="#string/menu_settings"/>
</menu>
I want to show the search item alwys and the other two in a dropdown, I made the showasaction as "collapseActionView" but am not getting any dropdown. Here's the sample pic of what am expecting. Thanks! :)
I just changed the code and order.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/menu_search"
android:icon="#drawable/share_ab"
android:showAsAction="always"
android:title="#string/menu_search"/>
<item
android:id="#+id/menu_share_app"
android:icon="#drawable/share_ab"
android:showAsAction="never"
android:title="#string/menu_share_app"/>
<item
android:id="#+id/menu_settings"
android:icon="#drawable/share_ab"
android:showAsAction="never"
android:title="#string/menu_settings"/>
</menu>
If you are having physical menu button (e.g. Nexus S) in your device then the dot line will not show. Even if your AVD emulates a device with has physical menu button then same thing will happen. When you press the Menu button it’ll show up.

Categories

Resources