I\'m following the example method to add a compatible preference/ fragment dialog found here. When doing so, I have found that if I have preferences that are Integers, Boolean,
There isn't a clean solution that I can find, but the best workaround seems to be something like this, using instanceof
to figure out what type of data you are dealing with.
private static void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
preference
.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
if (preference instanceof SeekBarPreference)
{
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(
preference,
PreferenceManager.getDefaultSharedPreferences(
preference.getContext()).getInt(preference.getKey(),0));
}
else if (preference instanceof CheckBoxPreference)
{
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(
preference,
PreferenceManager.getDefaultSharedPreferences(
preference.getContext()).getBoolean(preference.getKey(),true));
}
}