Problem with titles in PreferenceScreen (Android)

旧巷老猫 提交于 2019-12-25 08:59:38

问题


me again, working on some android live-wallpaper, again,

I have a small weird problem. I create a first level of for my settings, everything is OKAY. But at some point, I needed some sub level and create a new as an item of the first one like in the following example:

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

<PreferenceScreen android:title="Gray or Color">

  <CheckBoxPreference
    android:key="gray_color"
    android:summary="Gray"
    android:title="Use color ?"
    android:summaryOn="Color"
    android:summaryOff="Gray"
    android:persistent="true"/>

</PreferenceScreen>

</PreferenceScreen>

But the thing is, the title for the CheckBoxPreference doesn't appear, actually, it only appears when I press on it. And I have the same problem with other items too. What should I do ?

Thanks!

EDIT: Okay, now I see the problem, it's that the text is in black... Is there a way to change the color of the text of the force the backcolor of the preference screen ? like white or not black ?

EDIT 2: I solved the problem. I copy/paste some stuff from the manifest of CubeLiveWallpaper (the demo available with the SDK) and I shouldn't have kept the Theme, that was Theme.Light.WallpaperSettings. By removing it, I removed these problems.

Thanks for the help!


回答1:


Since preferences is just a special type of Activity, you have to add it in the Android manifest and add a title (label) there:

<activity
        android:name="Preferences"
        android:label="Gray or Color">
</activity>


来源:https://stackoverflow.com/questions/6714942/problem-with-titles-in-preferencescreen-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!