无法使用左侧的项目创建选项菜单,每个项目都有一个图标

时间:2022-11-20 08:09:02

This is my .xml file. How do I set icons for them?

这是我的.xml文件。如何为它们设置图标?

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_settings"/>
<item

    android:drawable="@android:color/white"
    android:id="@+id/Home"
    android:showAsAction="withText"
    android:icon="@drawable/homep"
    android:orderInCategory="1"
    android:title="@string/home"/>
<item
    android:showAsAction="withText"
    android:icon="@drawable/examp"
    android:id="@+id/Exam_not"
    android:orderInCategory="2"
    android:title="@string/exam"/>
<item   
    android:icon="@drawable/newsp"
    android:id="@+id/L_news"
    android:orderInCategory="3"
    android:showAsAction="withText"
    android:title="@string/L_news"/>
<item
    android:icon="@drawable/galleryp"
    android:id="@+id/gallery"
    android:orderInCategory="4"
    android:showAsAction="withText"
    android:title="@string/gallery"/>

How to set icons for them and create the menu on left side of device?

如何为它们设置图标并在设备左侧创建菜单?

It should look like this:

它应该如下所示:

无法使用左侧的项目创建选项菜单,每个项目都有一个图标

1 个解决方案

#1


0  

What you're showing appears to be a NavigationDrawer with either a number LinearLayout based rows, or backed by a ListView.

您正在显示的内容似乎是一个NavigationDrawer,它具有基于LinearLayout的行数,或者由ListView支持。

Refer to this tutorial from Google for more info: https://developer.android.com/training/implementing-navigation/nav-drawer.html

有关详情,请参阅Google的本教程:https://developer.android.com/training/implementing-navigation/nav-drawer.html

#1


0  

What you're showing appears to be a NavigationDrawer with either a number LinearLayout based rows, or backed by a ListView.

您正在显示的内容似乎是一个NavigationDrawer,它具有基于LinearLayout的行数,或者由ListView支持。

Refer to this tutorial from Google for more info: https://developer.android.com/training/implementing-navigation/nav-drawer.html

有关详情,请参阅Google的本教程:https://developer.android.com/training/implementing-navigation/nav-drawer.html