ActionBarSherlock - 显示溢出作用的项目,如图标+文字图标、作用、文字、项目

2023-09-04 23:49:42 作者:不二臣.

上下文

我创造了一些操作项目的操作杆,用ActionbarSherlock。它们中的一些溢出,所以它们显示在溢出子

I am creating an action bar with some action items, using ActionbarSherlock. Some of them are overflowed, so they are shown in the overflow submenu.

我的问题

这些溢出的项目显示在子菜单中只是作为单纯的文本。

Those overflowed items are shown in the submenu just as mere texts.

我已经试过 MenuItem.SHOW_AS_ACTION_IF_ROOM MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT setShowAsAction(),但都具有相同的行为:

I have tried MenuItem.SHOW_AS_ACTION_IF_ROOM and MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT for setShowAsAction() but both have the same behavior:

我要什么

时它可以显示在溢出子菜单中这些项目如< their_icon> + < their_text> ?事情是这样的:

Is it possible to show these items in the overflow submenu as <their_icon> + <their_text>? Something like this:

推荐答案

我不明白,要么为什么子菜单可以有图标和菜单只有文字。 也许添加菜单项子菜单到的根的菜单可以帮助你。 :)

I don't understand either why submenus can have icons and menus only text. Maybe adding menu items as submenus to the root menu could help you. :)

刚一提,增加的图标,如这将迫使你用动作条(福尔摩斯),而不是显示菜单的底部时,pressing在老版本的Andr​​oid的菜单键的标准方法。

Just a mention, adding icons like this will force you to use the ActionBar (Sherlock) and not the standard way of displaying menus at the bottom when pressing the menu key in older versions of Android.

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:id="@+id/root_menu"
    android:icon="@drawable/ic_menu_moreoverflow_normal_holo_light"
    android:showAsAction="always"
    android:title="More">
    <menu>
        <item
            android:id="@+id/menu_settings"
            android:icon="@drawable/ic_menu_settings_holo_light"
            android:showAsAction="never"
            android:title="Settings" />
        <item
            android:id="@+id/menu_about"
            android:icon="@drawable/ic_menu_info_details"
            android:showAsAction="never"
            android:title="About"/>
   </menu>
</item>
</menu>
 
精彩推荐
图片推荐