【问题标题】:Can't access res/drawable in xml file无法访问 xml 文件中的 res/drawable
【发布时间】:2014-09-03 02:56:51
【问题描述】:

我正在使用动画列表创建加载屏幕,但我遇到了一个错误,我无法访问我的 xml 文件中的 res/drawable 文件夹。我得到的错误是“找不到与给定名称匹配的资源(在'drawable',值为'@drawable/loadingwave0.png')”

目录res/anim/里面我的xml代码很简单:

<?xml version="1.0" encoding="utf-8"?>
<animation-list
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false" >  
    <item 
        android:drawable="@drawable/loadingwave0.png"
        android:duration="100" />    
</animation-list>

我注意到在我的项目标签中,Eclipse 不会预测任何可绘制资源,即使我已经将它们(未引用)复制到可绘制文件夹(hdpi、ldpi、mdpi)。如果我使用代码,我的 .png 图片可以通过我的 AndroidManifest.xml 文件访问

<item android:icon="@drawable/loadingwave0.png"/> 

用于确保可以访问可绘制文件夹。我已经多次清理和刷新了我的项目。

任何帮助将不胜感激。

【问题讨论】:

  • 你有drawable文件夹吗??

标签: android xml eclipse android-animation xml-drawable


【解决方案1】:

你应该使用:

<?xml version="1.0" encoding="utf-8"?>
<animation-list
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false" >  
    <item 
        android:drawable="@drawable/loadingwave0"
        android:duration="100" />    
</animation-list>

资源 id 是不带扩展名的文件名。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-24
    • 2014-06-17
    • 2013-10-07
    • 1970-01-01
    • 1970-01-01
    • 2017-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多