PreferenceScreen(Android)中标题的问题 [英] Problem with titles in PreferenceScreen (Android)

查看:504
本文介绍了PreferenceScreen(Android)中标题的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我,再次在一些android live-wallpaper上工作

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>

但是,事实是,没有出现CheckBoxPreference的标题,实际上,仅当我按下它时才显示它.我在其他物品上也有同样的问题.我该怎么办?

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 ?

谢谢!

好的,现在我看到了问题,这是文本为黑色...有没有办法改变强制文本的颜色,使首选项屏幕的背景色变强?喜欢白色还是不喜欢黑色?

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 ?

我解决了这个问题.我从CubeLiveWallpaper清单(SDK中提供的演示)的清单中复制/粘贴了一些东西,我不应该保留Theme,即Theme.Light.WallpaperSettings.通过删除它,我消除了这些问题.

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.

感谢您的帮助!

推荐答案

由于首选项只是Activity的一种特殊类型,因此您必须将其添加到Android清单中并添加标题(label)在那里:

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>

这篇关于PreferenceScreen(Android)中标题的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆