0

ActionBarActivity在我的活动中使用并膨胀以下菜单

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:microecs="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/menu_refresh"
    android:icon="@drawable/ic_action_refresh"
    android:title="@string/description_refresh"
    android:orderInCategory="1"
    microecs:showAsAction="ifRoom" />


<!--TODO: get a good logout icon-->
<item
    android:id="@+id/menu_logoff"
    android:icon="@drawable/ic_action_logout"
    android:title="@string/description_logoff"
    android:orderInCategory="2"

    microecs:showAsAction="never" />
</menu>

drawable我想要显示为 a而不是在操作栏中的第二个菜单项menu不会出现在我的S4(运行 4.3)以及运行2.3.7的较低设备上

4

2 回答 2

3

只需使用以下代码更新您的代码。

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:microecs="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/menu_refresh"
    android:icon="@drawable/ic_action_refresh"
    android:title="@string/description_refresh"
    android:orderInCategory="1"
    microecs:showAsAction="ifRoom" />


<!--TODO: get a good logout icon-->
<item
    android:id="@+id/menu_logoff"
    android:icon="@drawable/ic_action_logout"
    android:title="@string/description_logoff"
    android:orderInCategory="2"

    microecs:showAsAction="ifRoom" />
</menu>

每当您使用never时,它都不会将该项目放在操作栏中。

有关菜单,请参阅此链接

于 2013-10-01T11:00:16.050 回答
1

This is not possible by design. Overflow menus from the action bar don't show icons - that's just a design decision Google made.

You can check more, e.g. here: Displaying icon for menu items of Action Bar in Honeycomb android 3.0

于 2013-10-01T10:26:50.780 回答