开发者

Getting error message compiling android project

开发者 https://www.devze.com 2023-03-06 18:16 出处:网络
I\'m going through this tutorial from droid draw: http://www.droiddraw.org/tutorial3.html I\'m getting this error when I try to compile the code in eclipse:

I'm going through this tutorial from droid draw: http://www.droiddraw.org/tutorial3.html

I'm getting this error when I try to compile the code in 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').

Here are the contents of 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/widg开发者_如何学Cet30"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:entries="@arrays/items"
android:layout_x="0px"
android:layout_y="2px"
>
</ListView>
</AbsoluteLayout>

Here are the contents of 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>


Try instead

android:entries="@array/items"

It corresponds to R.array.items. The array resources are always called by its resource name, independent of the filename of the xml that defines it:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号