在内部preferenceScreen黑屏 [英] Black screen in inner preferenceScreen

查看:142
本文介绍了在内部preferenceScreen黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 preferenceActivity 包含嵌套 preferenceScreen 在另一 preferenceScreen 和我申请一个主题,我的 prefenceActivity 改变背景颜色。然而,当我打开嵌套的 preferenceScreen 我得到一个黑色的背景,我无法看到的选项。

My PreferenceActivity contains a nested PreferenceScreen in another PreferenceScreen and I'm applying a theme to my PrefenceActivity that changes the background color. However when I open the nested PreferenceScreen I get a black background and I cannot see the options.

这恰好与Android 2.1,但它不会发生与Android 1.6。 如何任何想法可以纠正?

This happens with android 2.1 , but it does not happen with android 1.6. Any ideas on how this can be corrected?

推荐答案

我找到了一种方法来做到这一点,但他看起来像一个黑客攻击。

I found a way to do it but it quite a hack.

这是我的 prefs.xml

<PreferenceCategory
    android:title="@string/hello">

    <CheckBoxPreference
        key="pref_update_key"
        android:title="@string/hello"
        android:summaryOn="@string/hello"
        android:summaryOff="@string/hello"
        android:persistent="true"
        android:defaultValue="false" />

</PreferenceCategory>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="pref_second_preferencescreen_key" android:title="@string/hello">
        <CheckBoxPreference
        key="pref_update_key"
        android:title="@string/hello"
        android:summaryOn="@string/hello"
        android:summaryOff="@string/hello"
        android:persistent="true"
        android:defaultValue="false" />
</PreferenceScreen>

这是我的code为的子类,preferenceActivity

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.prefs);
    getWindow().setBackgroundDrawableResource(R.drawable.background);

    PreferenceScreen b = (PreferenceScreen) findPreference("pref_second_preferencescreen_key");
    b.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            PreferenceScreen a = (PreferenceScreen) preference;
            a.getDialog().getWindow().setBackgroundDrawableResource(R.drawable.background);
            return false;
        }
    });
}

这篇关于在内部preferenceScreen黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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