我正在通过 droid draw 浏览本教程: http://www.droiddraw.org/tutorial3.html
当我尝试在 eclipse 中编译代码时出现此错误:
[2011-05-18 20:09:23 - DroidDrawTutorial1] /home/ollie/workspace/DroidDrawTutorial1/res/layout/main.xml:8: error: Error: No resource found that matches the given name (at 'entries' with value '@arrays/items').
这里是res/layout/main.xml的内容:
?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget29"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ListView
android:id="@+id/widget30"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:entries="@arrays/items"
android:layout_x="0px"
android:layout_y="2px"
>
</ListView>
</AbsoluteLayout>
这里是 res/values/arrays.xml 的内容:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<string-array name="items">
<item>item1</item>
<item>item2</item>
<item>item3</item>
</string-array>
</resources>
最佳答案
试试看
android:entries="@array/items"
它对应于R.array.items
。数组资源总是通过其资源名称调用,与定义它的 xml 的文件名无关:
http://developer.android.com/guide/topics/resources/string-resource.html#StringArray
String Array
An array of strings that can be referenced from the application.
Note: A string array is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine string array resources with other simple resources in the one XML file, under one element.
关于java - 获取编译android项目的错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6053513/