I use PreferenceActivity with encapsulated preference screens.
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="prefs" >
<PreferenceScreen android:title="@string/pref_user_1" >
some text preference
</PreferenceScreen>
<PreferenceScreen android:title="@string/pref_user_2" >
some prefs
<PreferenceScreen android:title="@string/pref_user_2_1" >
some prefs
</PreferenceScreen>
</PreferenceScreen>
</PreferenceScreen>
the inherited preactionActivity class has the following onCreate method
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PrefsFragment()).commit();
}
and has an inner class
public static class PrefsFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener {
public PrefsFragment() {
super();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.myprefs);
...
}
on the first screen, I get the correct icon in the action bar (I call it the action bar, even if I don't have <), but I would like to change the icon on the next screen.
I tried getActivity (). getActionBar (). setIcon (R.drawable.ic_act); in the inner class as well as in the Activity preference, but that doesn't change anything.
Does anyone know how to do this if possible?
source
share