0

I have two menu items: Settings and Exit. When I run my code, with both set to showAsAction:"always", none of them show up on the screen when I press the menu button on my phone. This also happens if I set both to "ifRoom". However, if I set one to "never", the other one will show up. How can I get both items to show up? I am running a ~3.5 inch android 4.1.2 phone. I am using the android:theme="@style/Theme.AppCompat" theme.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity" >

    <group android:checkableBehavior="single">

    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:orderInCategory="100"
        app:showAsAction="ifRoom|withText"
        android:icon="@drawable/sun"/>

    <item android:id="@+id/exit_the_app"
        android:title="@string/options_exit_text"
        app:showAsAction="ifRoom|withText"
        android:orderInCategory="101"
        android:icon="@drawable/night"/>
    </group>
</menu>

This is the screen when both items are set to "always" or "ifRoom", no menu items show up: two muppets This is the screen when settings is set to "never", the exit item shows up:
ttwtw There seems to be enough room, so how do I make both items show up? Thank you.

4

1 回答 1

0

当 showAsAction 设置为 ifRoom 或始终显示在操作栏中而不是溢出菜单中时(仅在 ifRoom 的情况下有空间时)。这是预期的行为。

如果您希望它们都显示在溢出菜单中,请将两者的 showAsAction 设置为 never。

我建议阅读文档:http: //developer.android.com/guide/topics/ui/actionbar.html

于 2014-08-15T18:51:25.520 回答