android - 首选项屏幕为白色

标签 android android-preferences preferencescreen

我尝试学习 Android 并决定创建 SettingsActivity。但是我遇到了在 PreferenceScreen 上看不到任何文本的问题。我的 PreferenceScreen 在设计模式下是白色的,所以我在那里看不到任何文本。

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <PreferenceCategory app:title="@string/messages_header">

        <EditTextPreference
            app:key="signature"
            app:title="@string/signature_title"
            app:useSimpleSummaryProvider="true" />

        <ListPreference
            app:defaultValue="reply"
            app:entries="@array/reply_entries"
            app:entryValues="@array/reply_values"
            app:key="reply"
            app:title="@string/reply_title"
            app:useSimpleSummaryProvider="true" />

    </PreferenceCategory>

    <PreferenceCategory app:title="@string/sync_header">

        <SwitchPreferenceCompat
            app:key="sync"
            app:title="@string/sync_title" />

        <SwitchPreferenceCompat
            app:dependency="sync"
            app:key="attachment"
            app:summaryOff="@string/attachment_summary_off"
            app:summaryOn="@string/attachment_summary_on"
            app:title="@string/attachment_title" />

    </PreferenceCategory>
    <PreferenceCategory
        app:title="@string/help_header">
    </PreferenceCategory>

</PreferenceScreen>

no text in design mode

我的项目几乎是空的,Android Studio 是全新安装的。

最佳答案

我也遇到过这种情况。在我将 app:title 替换为 android:title 后,文本才开始出现。问题是我还不知道为什么。

关于android - 首选项屏幕为白色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58125675/

相关文章:

android - 使用 AndroidX 首选项的自定义首选项

android - PreferenceFragmentCompant 在 rootKey 上的 onCreatePreferences 中显示为空

java - 如何为标准对话框 PreferenceFragmentCompat 设置 Cancelable(false)

java - Android 添加不起作用的应用程序类

android - 如何将 http post 从 android 发送到 google app engine 服务器?

android - Android 的 DisplayMetrics xdpi 和 ydpi 总是相等吗?

java - Android N - 在运行时更改区域设置

android - 如何将 SetOnClickListener() 设置为 EditTextPreference 对话框的确定​​按钮?

java - 删除后无法插入相同的对象

Android SwitchPreference 在 4.2.2 中无法正常工作