Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取编译android项目的错误消息_Java_Android - Fatal编程技术网

Java 获取编译android项目的错误消息

Java 获取编译android项目的错误消息,java,android,Java,Android,我将学习droid draw的本教程: 当我尝试在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/

我将学习droid draw的本教程:

当我尝试在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>
?xml version=“1.0”encoding=“utf-8”>
以下是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>

项目1
项目2
项目3
试试看

android:entries="@array/items"
它对应于
R.array.items
。数组资源始终按其资源名调用,与定义它的xml文件名无关:

字符串数组

可以从应用程序引用的字符串数组

注意:字符串数组是一个简单的资源,它使用name属性中提供的值(而不是XML文件的名称)进行引用。因此,您可以将字符串数组资源与一个XML文件中的其他简单资源组合在一个元素下


教程中的文本不一致。我认为@array只需要匹配文件名;在我的例子中是arrays.xml。你确实是对的——这就是我依靠直觉得到的。谢谢你的帮助。不,如果你是从教程里拿的,肯定是打字错误。文件名不相关。请参阅我的最新答案。编辑:有时文档帮助;)