MultiSelectListPreference 由于xml存在问题而崩溃

0

本文作者:xjtudll  发布于:2017-11-14  分类:技术心得  点击:


参考资料:

http://stackoverflow.com/questions/28687681/multiselectlistpreference-crashes-with-dependency

问题描述:

添加了一个MultiSelectListPreference,然后一运行程序,就崩溃了。

andrpid API:19,是支持MultiSelectListPreference的。

xml文件如下:

preferences.xml:

<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">   <CheckBoxPreference         android:key="early"         android:title="@string/early"         android:summary="@string/early_summ"         android:defaultValue="false"/>  <PreferenceCategory         android:title="@string/time_remaining"         android:key="time_remaining">      <CheckBoxPreference             android:key="time_remaining_vibrate"             android:title="@string/remain_vibrate"             android:summary="@string/remain_vibrate_summ"             android:disableDependentsState="true"             android:defaultValue="false"/>      <MultiSelectListPreference             android:key="time_remaining_vibrate_times"             android:title="@string/remain_vibrate_times"             android:summary="@string/remain_vibrate_times_summ"             android:entries="@array/empty_array"             android:entryValues="@array/empty_array"             android:dependency="time_remaining_vibrate"/>  </PreferenceCategory>  </PreferenceScreen>
解决办法:

在 MultiSelectListPreference中添加:

android:defaultValue="@array/empty_array"

The other problem I had was a string cannot be cast as set exception, but that was fixed by clearing the app's data in settings.

0 Comments

Write a comment ?