开发者

Honeycomb Drop-down options menu. How to show?

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.setListN开发者_如何学PythonavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

Can anybody help me? Thanks!

upd.. I want like something(here is menu. I need the same for Share-betton):

Honeycomb Drop-down options menu. How to show?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜