如何设置PreferenceActivity/preferenceScreen的背景色
展开全部
1、在value文件夹下新建一个systemset.xml文件,sytemset.xml内容
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="sys_set_preacitivity">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:focusable">false</item>
<item name="android:textColor">#ff000000</item>
<item name="android:cacheColorHint">#ffffffff</item>
<item name="android:windowNoTitle">false</item> <!-- 用来设定是否显示标题 -->
</style>
</resources>
2、在AndroidManifest.xml调用
<activity android:name="SystemSetAcitivity" android:theme="@style/sys_set_preacitivity"></activity>
4、新建一个xml文件,在xml下新建一个system_set.xml,内容是
<?xml version="1.0" encoding="utf-8"?>
<preferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/systemTitle" android:layout="@layout/system_set">
<preferenceCategory android:title="@string/soundTitle">
<CheckBoxPreference android:title="@string/muteTitle"
android:summary="@string/muteSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/shockTitle"
android:summary="@string/shockSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/soundTitle"
android:summary="@string/soundSum"></CheckBoxPreference>
</PreferenceCategory>
<preferenceCategory android:title="@string/soundTitle">
<CheckBoxPreference android:title="@string/muteTitle"
android:summary="@string/muteSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/shockTitle"
android:summary="@string/shockSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/soundTitle"
android:summary="@string/soundSum"></CheckBoxPreference>
</PreferenceCategory>
</PreferenceScreen>
4、在src下新建一个java文件
package com.android.perference.acitivity;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
public class SystemSetAcitivity extends PreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.system_set);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference)
{
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="sys_set_preacitivity">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:focusable">false</item>
<item name="android:textColor">#ff000000</item>
<item name="android:cacheColorHint">#ffffffff</item>
<item name="android:windowNoTitle">false</item> <!-- 用来设定是否显示标题 -->
</style>
</resources>
2、在AndroidManifest.xml调用
<activity android:name="SystemSetAcitivity" android:theme="@style/sys_set_preacitivity"></activity>
4、新建一个xml文件,在xml下新建一个system_set.xml,内容是
<?xml version="1.0" encoding="utf-8"?>
<preferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/systemTitle" android:layout="@layout/system_set">
<preferenceCategory android:title="@string/soundTitle">
<CheckBoxPreference android:title="@string/muteTitle"
android:summary="@string/muteSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/shockTitle"
android:summary="@string/shockSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/soundTitle"
android:summary="@string/soundSum"></CheckBoxPreference>
</PreferenceCategory>
<preferenceCategory android:title="@string/soundTitle">
<CheckBoxPreference android:title="@string/muteTitle"
android:summary="@string/muteSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/shockTitle"
android:summary="@string/shockSum"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/soundTitle"
android:summary="@string/soundSum"></CheckBoxPreference>
</PreferenceCategory>
</PreferenceScreen>
4、在src下新建一个java文件
package com.android.perference.acitivity;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
public class SystemSetAcitivity extends PreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.system_set);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference)
{
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询