我在我的应用程序中设置了一个铃声偏好,但当我选择想要的铃声时,它不会被存储在偏好值中。我可以再次点击该偏好项,但它不会显示我刚刚选择的内容。
以下是XML代码:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Audio Settings">
<CheckBoxPreference
android:key="SMS_PREF_TTS"
android:title="Say name of sender"
android:summary="When a person in your contact list sends you a sms/mms message its says their name"
android:defaultValue="false">
</CheckBoxPreference>
<CheckBoxPreference
android:key="SMS_PREF_TTS_MSG"
android:title="Say Message"
android:summary="Will say the message of sender from contact list"
android:dependency="SMS_PREF_TTS"
android:defaultValue="false">
</CheckBoxPreference>
<RingtonePreference
android:key="SMS_PREF_SOUND"
android:title="Change Sound"
android:ringtoneType="notification"
android:summary="Select the notification Sound"
android:dialogTitle="Change Sound"
android:defaultValue="Silent">
</RingtonePreference>
</PreferenceCategory>
</PreferenceScreen>
“奇怪的是,我刚刚为应用程序的另一部分编写了另一个 XML 文件,铃声偏好设置看起来也是这样的,但那个可以运行,所以我不明白。”
“这是一个可工作的示例:”
<RingtonePreference
android:key="CAL_PREF_TONE"
android:title="Default ringtone"
android:summary="Select default notification ringtone"
android:ringtoneType="notification"
android:defaultValue="Silent"
android:dependency="CAL_PREF_ON">
</RingtonePreference>