我在我的应用程序中有一个铃声首选项,但是当我选择我想要的铃声时,它不会存储在首选项值中。我可以再次点击该偏好设置,它不会显示我刚刚选择的内容。铃声首选项不保存选择
这里是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>
我能想到的唯一的事情就是你在其他一些pref中使用了SMS_PREF_SOUND,并且这会覆盖你的选择。除此之外(除非你在PreferenceActivity中做某件事),绝对没有理由不存储它。 – IncrediApp
我也尝试过改变'钥匙',它仍然不能保存它 – tyczj