1

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/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>

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>

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

The text in the tutorial is inconsistent. I think the @arrays just needs to match the name of the file; which in my case is arrays.xml.
You are indeed correct - that's what I get for relying on my intuition. Thanks for your help.
No, if you took it from a tutorial, it must be a typo in there. The filename is not relevant. See my updated answer. Edit: sometimes the docs help ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.