根据选中的状态更改CheckBoxPreference摘要

Swe*_*now 6 checkbox android checked android-preferences

我正在尝试创建一个应用程序,其中首选项摘要根据已检查的状态更改CheckBoxPreference.

我不太确定如何查询首选项,因为好的旧版本isChecked()不起作用.

Jay*_*dri 17

如果您刚刚使用android:summaryOffandroid:summaryOn在您的偏好布局中会更简单.无需代码.例如:

<CheckBoxPreference
        android:enabled="true"
        android:key="alerts"
        android:title="Alerts" 

        android:summaryOn="You will get notified when something interesting happens"
        android:summaryOff="You will not be notified"
        /> 
Run Code Online (Sandbox Code Playgroud)

请参阅:http://developer.android.com/reference/android/preference/CheckBoxPreference.html