-1

In CheckBoxPreference, what is the difference between "android:defaultValue" and "android:checked"? Both seems to be doing the same thing

<CheckBoxPreference
    android:key="pref_"
    android:title=""
    android:summary=""
    android:defaultValue="true"
    android:checked="true">
</CheckBoxPreference>
4

2 回答 2

0

@andychen 默认值标签定义了如果用户没有明确地为复选框存储任何值,则应该从首选项中获取什么值。并且标签检查定义了应该在屏幕初始化时向用户显示复选框的状态

于 2017-04-25T07:16:11.447 回答
0

Sets the checked state and saves it to the SharedPreferences. And Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.

于 2017-04-25T06:15:02.527 回答