I have a PreferenceScreen defined in an XML-file like this:
<PreferenceCategory android:title="Choose Days">
<PreferenceScreen android:title="Days of Week" android:key="daysOfWeek">
<CheckBoxPreference android:title="Mondays" android:key="chkMonday"></CheckBoxPreference>
<CheckBoxPreference android:title="Tuesdays" android:key="chkTuesday"></CheckBoxPreference>
<CheckBoxPreference android:title="Wednesdays" android:key="chkWednesday"></CheckBoxPreference>
<CheckBoxPreference android:title="Thursdays" android:key="chkThursday"></CheckBoxPreference>
<CheckBoxPreference android:title="Fridays" android:key="chkFriday"></CheckBoxPreference>
<CheckBoxPreference android:title="Saturdays" android:key="chkSaturday"></CheckBoxPreference>
<CheckBoxPreference android:title="Sundays" android:key="chkSunday"></CheckBoxPreference>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="Other Settings">
<CheckBoxPreference android:title="Enable" android:defaultValue="true" android:key="enable"></CheckBoxPreference>
</PreferenceCategory>
When I click on the PreferenceScreen:daysOfWeek the checkboxes appear, og when I check or uncheck a box, the onSharedPreferenceChanged is triggered.
This is because of this:
public class Muteny extends PreferenceActivity implements OnSharedPreferenceChangeListener {
and register it in onResume and unregister it in onPause in my .java file.
A simplified onSharedPreferenceChanged looks like this:
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
PreferenceScreen daysOfWeek = ((PreferenceScreen)findPreference("daysOfWeek"));
daysOfWeek.setSummary("text for summary");
Toast.makeText(this.getApplicationContext(), "Hello", Toast.LENGTH_LONG).show();
}
The problem is that the summary of "daysOfWeek" is never updated. If I then switch the CheckBoxPreference "enable" (which does nothing at the moment, but trigger the change), the summary is updated as I wanted it to do when switching the "day-boxes".
The message in Toast IS displayed though...
How do I update the summary of my PreferenceScreen when checking the "day boxes"?