如何在android动作菜单中显示带有文本的图标列表,如图像

时间:2015-07-28 09:01:26

标签: android menu android-actionbar action

Menu picture

我想显示一个选项弹出窗口,例如点击操作按钮上的图像(3 ...图标)。

我试图通过选项菜单来做,但图标不会到来。请建议我如何添加图标。

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

<item
    android:id="@+id/action_view_details"
    android:title="View room details"
    android:orderInCategory="100"
    android:icon="@drawable/ic_dealroom_details_normal"
    app:showAsAction="never" />

<item
    android:id="@+id/action_add_file"
    android:title="@string/action_create_file"
    android:orderInCategory="100"
    android:icon="@drawable/ic_dealroom_createfolder_normal"
    app:showAsAction="never" />

<item
    android:id="@+id/action_add_folder"
    android:title="@string/action_create_folder"
    android:icon="@drawable/ic_dealroom_createfile_normal"
    android:orderInCategory="100"
    app:showAsAction="never" />

<item
    android:id="@+id/action_upload_from_camera"
    android:title="@string/action_upload_from_camera"
    android:icon="@drawable/ic_dealroom_uploadcamera_normal"
    android:orderInCategory="100"
    app:showAsAction="never" />

<item
    android:id="@+id/action_upload_from_gallery"
    android:title="@string/action_upload_from_gallery"
    android:icon="@drawable/ic_dealroom_uploadgallery_normal"
    android:orderInCategory="100"
    app:showAsAction="never" />
<item
    android:id="@+id/action_upload_from_local"
    android:title="@string/action_upload_from_local"
    android:orderInCategory="100"
    android:icon="@drawable/ic_dealroom_upload_normal"
    app:showAsAction="never" />

1 个答案:

答案 0 :(得分:11)

<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">

    <item
        android:id="@+id/action_more"
        android:icon="@drawable/ic_more_white"
        android:title="@string/action_more"
        android:orderInCategory="100"
        app:showAsAction="always">
        <menu>
            <item
                android:id="@+id/action_settings"
                android:icon="@drawable/ic_settings_black"
                android:title="@string/action_settings"
                android:orderInCategory="100"
                app:showAsAction="never" />

            <item ... />
        </menu>

    </item>

</menu>

ic_more_white是3的图标...... 我希望这可以帮到你。