在menu.xml中找不到资源错误

时间:2012-11-22 10:06:40

标签: android menu

这是我的菜单类型android xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <group android:id="@+id/rose" android:menuCategory="container" android:visible="true">
        <item android:icon="@drawable/login.png"  android:id="@layout/activity_login_page"></item>
        <item android:id="@layout/activity_registration__page" android:icon="@drawable/registration.png"></item>
        <item android:id="@layout/activity_online_shopping" android:icon="@drawable/shopping.png"></item>
        <item android:id="@layout/activity_your_total_bill" android:icon="@drawable/logout.png"></item>
    </group>
</menu>

这是我发现的错误,但我的资源都在我的drawable文件夹中

 W/ResourceType( 3000): Bad XML block: header size 116 or total size 0 is larger than data size 0
[2012-11-22 15:32:20 - OrderPlacemnet] E:\workspace\OrderPlacemnet\res\menu\rosemenu.xml:4: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/login.png').
[2012-11-22 15:32:20 - OrderPlacemnet] E:\workspace\OrderPlacemnet\res\menu\rosemenu.xml:5: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/registration.png').
[2012-11-22 15:32:20 - OrderPlacemnet] E:\workspace\OrderPlacemnet\res\menu\rosemenu.xml:6: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/shopping.png').
[2012-11-22 15:32:20 - OrderPlacemnet] E:\workspace\OrderPlacemnet\res\menu\rosemenu.xml:7: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/logout.png').

请帮我查找错误

2 个答案:

答案 0 :(得分:0)

请在菜单中删除.png

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <group android:id="@+id/rose" android:menuCategory="container" android:visible="true">
        <item android:icon="@drawable/login"  android:id="@layout/activity_login_page"></item>
        <item android:id="@layout/activity_registration__page" android:icon="@drawable/registration"></item>
         <item android:id="@layout/activity_online_shopping" android:icon="@drawable/shopping"></item>
          <item android:id="@layout/activity_your_total_bill" android:icon="@drawable/logout"></item>
    </group>



</menu>

答案 1 :(得分:0)

您的问题是由菜单项的.png标记中包含src引起的。你不应该包括它。您的菜单代码应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <group android:id="@+id/rose" android:menuCategory="container" android:visible="true">
        <item android:icon="@drawable/login"  android:id="@layout/activity_login_page"></item>
        <item android:id="@layout/activity_registration_page" android:icon="@drawable/registration"></item>
        <item android:id="@layout/activity_online_shopping" android:icon="@drawable/shopping"></item>
        <item android:id="@layout/activity_your_total_bill" android:icon="@drawable/logout"></item>
    </group>
</menu>