问题描述
我的 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黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!