Ho trovato un modo per farlo ma è un bel compromesso.
Questo è il mio 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>
E questo è il mio codice per la classe che extends 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;
}
});
}
potresti fornire alcuni registri/altri dati? –