Based on the following code, can you tell me how to refresh the PreferenceActivity window to show changes in the settings immediately? For example: the user taps the master
After fighting this for a day, I figured out this.
This is for multiple levels of preferences.
parent is the preference screen that holds the preference you are trying to update.
Since the settings screen displays as a dialog, you can get the listview from the dialog, then tell it's adapter to update child.
PreferenceScreen parent // The screen holding the child
PreferenceScreen child // The entry changing
child.setSummary(isEnabled?"Enabled":"Not Enabled");
ListView v = (ListView)parent.getDialog().findViewById(android.R.id.list);
BaseAdapter ba = (BaseAdapter)v.getAdapter();
ba.notifyDataSetChanged();
I found R.id.list is not available on older phones but this works
ListAdapter adapter = parent.getRootAdapter();
if (adapter instanceof BaseAdapter) {
((BaseAdapter)adapter).notifyDataSetChanged();
}