Questions tagged «listpreference»

4
ListPreference:使用字符串数组作为条目,使用整数数组作为条目值不起作用
我在settings.xml文件中使用ListPreference。我想向用户显示3个选项列表。当用户在“设置”中选择一个选项时,出现此错误: java.lang.NullPointerException at android.preference.ListPreference.onDialogClosed(ListPreference.java:264) at android.preference.DialogPreference.onDismiss(DialogPreference.java:381) at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1228) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) 这是ListPreference的代码: <ListPreference android:entries="@array/date_alignement" android:entryValues="@array/date_alignement_values" android:key="settings_date_alignement" android:summary="@string/settings_date_alignement_summary" android:title="@string/settings_date_alignement_title" /> 这是我用来填充条目的数组: <string-array name="date_alignement"> <item>"Top"</item> <item>"Center"</item> <item>"Bottom"</item> </string-array> <integer-array name="date_alignement_values"> <item >0</item> <item >1</item> <item >2</item> </integer-array> …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.