简体   繁体   English

错误的XML块,错误:找不到与给定名称匹配的资源(在'icon'处,值为'@android:drawable

[英]Bad XML block, Error: No resource found that matches the given name (at 'icon' with value '@android:drawable

Background: I am using Eclipse to develop an Android app. 背景:我正在使用Eclipse开发Android应用程序。 I have an xml file that contains a menu that contains three items. 我有一个xml文件,其中包含一个包含三个项目的菜单。 Each of the items contains an android:icon declaration. 每个项目都包含一个android:icon声明。 Only the first android:icon declaration is referenced in my program. 我的程序中仅引用了第一个android:icon声明。 NOTE: The second two android:icon declarations are NOT referenced ANYWHERE in my program or in any of the project files. 注意:在我的程序或任何项目文件中,后两个android:icon声明均未引用。

The Problem: I tried in vain to add a fourth menu item and discovered something very baffling to me. 问题:我徒劳地尝试添加第四个菜单项,发现有些令我困惑的东西。 Not only cannot I not add an item to my menu, I cannot alter the existing last two android:icon declarations or I get the errors described in the title. 我不仅不能不向菜单中添加项目,还不能更改现有的最后两个android:icon声明,或者得到标题中描述的错误。 For example I cannot change the following android:icon declaration from: 例如,我不能从以下更改以下android:icon声明:

android:icon="@android:drawable/ic_menu_preferences"

To: 至:

android:icon="@android:drawable/ic_menu_preference"

I find this very baffling because the android:icon is declared but not referenced anywhere in my program or in any of the project files. 我觉得这很令人困惑,因为android:icon已声明但未在我的程序或任何项目文件中的任何地方引用。 And none of the "solutions" I found on the internet fix my problem. 我在互联网上找到的所有“解决方案”都无法解决我的问题。 And as I write this Stackoverflow is telling me my question has been asked and answered, but it hasn't! 当我写这篇文章时,Stackoverflow告诉我我的问题已被提出并得到了回答,但事实并非如此!

Any ideas anyone? 有任何想法吗?

NOTE: The second two android:icon declarations are NOT referenced ANYWHERE in my program or in any of the project files 注意:我的程序或任何项目文件中均未引用后两个android:icon声明

They are in your menu. 它们在您的菜单中。 Otherwise, the android:icon attributes would not exist. 否则, android:icon属性将不存在。 Hence, the icons are referenced by the menu itself. 因此,菜单本身会引用这些图标。

For example I cannot change the following android:icon declaration 例如,我不能更改以下android:icon声明

That is because there is no icon in the OS with that name . 这是因为操作系统中没有带有该名称的图标

Also, unless every icon you use in your menu will come from the OS, you are better served by copying them from your SDK into your project. 另外,除非菜单中使用的每个图标都来自操作系统,否则最好将它们从SDK复制到项目中,以更好地为您服务。 Some OEMs replace the standard icons with their own versions. 一些OEM用其自己的版本替换标准图标。 If you will be mixing OS icons with your own icons, even if you design your icons to match those on, say, the emulator, they will not match on other devices. 如果将OS图标与自己的图标混合使用,即使您设计的图标与仿真器上的图标匹配,它们也不会在其他设备上匹配。 By copying the icons from the SDK into your project, you ensure consistency within your menu -- if the icons look right on the emulator, they will look the same on other devices. 通过将图标从SDK复制到项目中,可以确保菜单内的一致性-如果图标在模拟器上正确显示,则它们在其他设备上的外观相同。

I find this very baffling because the android:icon is declared but not referenced anywhere in my program or in any of the project files. 我觉得这很令人困惑,因为android:icon已声明但未在我的程序或任何项目文件中的任何地方引用。

The icon is part of the menu. 该图标是菜单的一部分。 Otherwise, the android:icon attribute would not exist. 否则, android:icon属性将不存在。 Hence, the non-existent icon is referenced by the menu itself. 因此,菜单本身会引用不存在的图标。

The line @android:drawable/ic_menu_preferences is actually a reference itself. @android:drawable/ic_menu_preferences行实际上是一个引用本身。 It is referencing a standard Android image that is displayed on your menu item. 它引用的是菜单项上显示的标准Android图像。 Here is some documentation to help you with drawables. 以下是一些可帮助您使用可绘制对象的文档

i think , you have added a png file which is corrupted 我认为,您已添加了已损坏的png文件

follow this link , probably it will help you 点击此链接 ,可能会对您有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:找不到与给定名称匹配的资源(在&#39;icon&#39;处,值为&#39;@ drawable / icon&#39;) - Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon') 错误:在Cordova中找不到与给定名称(在&#39;icon&#39;处,值为&#39;@ drawable / icon&#39;)相匹配的资源 - Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon') in Cordova cmd:命令失败,退出代码为1,错误:找不到与给定名称匹配的资源(在&#39;icon&#39;处,值为&#39;@ drawable / icon&#39;) - cmd: Command failed with exit code 1, Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon') 错误:(16、23)找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / icon”) - Error:(16, 23) No resource found that matches the given name (at 'icon' with value '@drawable/icon') Unity项目中的错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error in Unity project : No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher') 错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher') 错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error: No resource found that matches the given name (at 'icon' with value '@drawable/ ic_launcher') 在Android Studio中构建项目时出错“错误:找不到与给定名称匹配的资源(在____处使用值&#39;@ drawable / <name> “) - Error Building Project in Android Studio "Error: No resource found that matches the given name (at ____ with value '@drawable/<name>') apktool编译错误未找到与给定名称匹配的资源(在&#39;pointDrawable&#39;处,值为&#39;@ android:drawable / APKTOOL_DUMMY_0302&#39; - apktool compile error No resource found that matches the given name (at 'pointDrawable' with value '@ android:drawable/APKTOOL_DUMMY_0302' 找不到与给定名称匹配的资源(在“ icon”处具有值…) - No resource found that matches the given name (at 'icon' with value …)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM