I'm a bit unclear on how Preference.setSummary() is supposed to work. Is this method supposed to update a menu item's summary in a Preference fragment in a non-volatile way? In other words, is the displayed summary supposed to persist after closing and re-opening the preference menu fragment?
I thought it is supposed to work like this, yet any time I press the back button and then re-open the preference menu the summaries are blank again.
public class FragmentSettingsMenu extends com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat {
private SharedPreferences.OnSharedPreferenceChangeListener listener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from the XML resource
addPreferencesFromResource(R.xml.preferences);
listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (key.equals("pref_wood")) {
Preference woodPref = findPreference(key);
String color = woodPref.getSharedPreferences().getString(key, "Maple");
MainActivity.getGLSurfaceView().setTexture(color);
woodPref.setSummary(color); // Set summary to be the user-description for the selected value
}
}
};
}
}
Is this method supposed to update a menu item's summary in a Preference fragment in a non-volatile way?
No.
In other words, is the displayed summary supposed to persist after closing and re-opening the preference menu fragment?
No.