错误:错误:不允许字符串类型(在'条目'处,值为'array/list')

5 android android-preferences

我是android开发和使用eclipe软件开发pref.xml(资源类型prefrence)的新手.这是我的pref.xml代码

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

<EditTextPreference
 android:title="EditText"
 android:key = "name"
 android:summary="Enter Your name"
 ></EditTextPreference>

 <CheckBoxPreference
 android:title="CheckBox"
 android:defaultValue="true"
 android:key="checkBox"
 android:summary="check this box"
 ></CheckBoxPreference>

 <ListPreference
 android:title="List"
 android:key="list"
 android:summary="This Is A List To Choose From"
 android:entries="array/list"
 ></ListPreference>
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

error: Error: String types not allowed (at 'entries' with value 'array/list')
Run Code Online (Sandbox Code Playgroud)

请帮帮我..我该如何处理这个错误?

小智 3

在包资源管理器的 res\value 文件夹中查找文件名 strings.xml...在此文件中添加以下行

<string-array name="list"></string-array>
Run Code Online (Sandbox Code Playgroud)

你的最终文件看起来像

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Muzafar Khan</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>

<string-array name="list"></string-array>
Run Code Online (Sandbox Code Playgroud)

现在保存您的项目...并享受:)