android - ListPreference 默认值未显示

标签 android settings default-value listpreference

我尝试为 ListPreference 设置默认值,但没有任何显示。

你能检查我的代码是否有错误吗?

谢谢。

真的, 埃马德

这是在 settings.xml 文件中:

<PreferenceCategory android:title="Media:">
    <CheckBoxPreference android:key="ChimeWhenMusicIsPlaying"
        android:title="@string/ChimeWhenMusicIsPlayingTitle" android:summary="@string/ChimeWhenMusicIsPlayingSummary"
        android:defaultValue="false" />

    <ListPreference android:title="Chime Volume"
        android:key="ChimeVolume" android:summary="Select volume for the chiming sound."
        android:entries="@array/chimeVolumeLabels" android:entryValues="@array/chimeVolumeValues"
        android:defaultValue="1" />

</PreferenceCategory>

这是在数组文件中:

<resources>

    <string-array name="chimeVolumeLabels">
    <item>Default</item>
    <item>Soft</item>
    <item>Medium</item>
    <item>Loud</item>
    </string-array>

    <string-array name="chimeVolumeValues">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    <item>4</item>
    </string-array>
</resources>

最佳答案

我发现有时候我需要清除应用程序数据。卸载并重新安装该应用程序。之后,一切都按预期进行。

关于android - ListPreference 默认值未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7342557/

相关文章:

android - 右侧带有图标的 Material 按钮

android - 游戏服务与应用的区别

java.lang.RuntimeException : Unable to start activity

windows - 如何以编程方式配置 Windows cmd.exe 设置?

select - 以编程方式设置多选/选择 Magento 属性的默认值

java - AndroidManifest.xml 文件中缺少 MapService

ios - 读取“设置包”简单值的值

iphone - 如何从 iPhone 应用程序中将用户引导至 iPhone 设置主屏幕

c# - 组合框默认值始终是 SQL 表值 - C#

java - HashMap 中的默认值