java - 获取编译android项目的错误信息

标签 java android

我正在通过 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/

相关文章:

java - Collections.sort 与比较器返回常量

Java 通过套接字传输多个文件

搜索完成时的Android exoplayer回调

android - 设置刷新率后 AdMob android 点击率下降

android - 拖动后如何将布局恢复到其在android中的原始位置

Java : How to sort an array of floats in reverse order?

java - 为什么我无法检索刚刚保留的实体?

Android volley post 请求在正文中带有 json 对象并在 String 中获得响应

android - 如何将字节数组转换为位图图像?

java - Android ListView 中包含的 EditText 内容未保存