I’ve passes by this tutorial:
Android: Creating and populating ListView items in XML
I want to initialize a ListView in the xml not the code.
my array.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="anyArray">
<item>one</item>
<item>two</item>
<item>three</item>
</string-array>
</resources>
my activity_main.xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/listView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:entries="@array/anyArray" >
</ListView>
</RelativeLayout>
When I switch to the layout, I get this warning
Couldn't resolve resource @array/anyArray
and no items are displayed. How can I fix this problem?
Your resources’ names should only contain [a-z0-9._]. Rename your
Arrayto all lower case characters.