我是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)
现在保存您的项目...并享受:)
| 归档时间: |
|
| 查看次数: |
4334 次 |
| 最近记录: |