Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDerek Kneisel
2,487 PointsArray error
For the Blog Reader app I just created an array and I get this message in the MainListActivity.java " array cannot be resolved or is not a field ". In the strings.xml I get an error saying " Attribute name "Android" associated with an element type "item" must be followed by the ' = ' character "
Kristen Law
16,244 Pointsstrings.xml looks fine.. what is the error you're getting in the above code?
1 Answer
Kristen Law
16,244 PointsCan you post your code from your strings.xml file? Check to make sure your syntax is correct.
Does each item look like this inside the string-array
tag?
<item>value</item>
Kristen Law
16,244 Pointslooks like you forgot the closing angle bracket for your item
tags
Derek Kneisel
2,487 Pointsstill get an error on line 2: Multiple annotations found at this line: - Attribute name "Android" associated with an element type "item" must be followed by the ' = ' character.
<string-array name ="android_names">
<item>Android beta</item>
<item>Android 1.0 </item>
<item>Android 1.1</item>
<item>Cupcake</item>
<item>Donut</item>
<item>Eclair </item>
<item>Froyo</item>
<item>Gingerbread</item>
<item>Honeycomb </item>
<item>Ice Cream Sandwhich</item>
<item>Jelly Bean</item>
</string-array>
Kristen Law
16,244 PointsThe code you posted in the above comment is correct so the problem is probably somewhere else. Can you post the code for your entire strings.xml file?
Derek Kneisel
2,487 Points<?xml version="1.0" encoding="utf-8"?> <resources>
<string name="app_name">BlogReader</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="no_items">No items to display!</string>
<string-array name ="android_names">
<item>Android beta</item>
<item>Android 1.0 </item>
<item>Android 1.1</item>
<item>Cupcake</item>
<item>Donut</item>
<item>Eclair </item>
<item>Froyo</item>
<item>Gingerbread</item>
<item>Honeycomb </item>
<item>Ice Cream Sandwhich</item>
<item>Jelly Bean</item>
</string-array>
</resources>
Derek Kneisel
2,487 PointsDerek Kneisel
2,487 Pointserror on line 19
MainListActivity.java
package net.kneisel.blogreader;
import android.app.ListActivity; import android.content.res.Resources; import android.os.Bundle; import android.view.Menu; import android.widget.ArrayAdapter;
public class MainListActivity extends ListActivity {
}