我已经通过了本教程:
Android:在 XML 中创建和填充列表视图项
我想在 xml 而不是代码中初始化列表视图。
我的数组.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="anyArray">
<item>one</item>
<item>two</item>
<item>three</item>
</string-array>
</resources>
我的activity_main.xml文件:
<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>
当我切换到布局时,我收到此警告
Couldn't resolve resource @array/anyArray
并且不显示任何项目。如何解决此问题?
资源的名称应仅包含 [a-z0-9._]。将Array
重命名为所有小写字符。