android - SharedPreferences dependencies -


i wanted create listpreference which, when changed reload values of others listpreference objects. tried calling:

if(key.equals("important_pref")) {   sharedpreferences.editor editor = sharedpreferences.edit();   editor.putstring("some_pref", "some_val");   editor.apply(); } 

in onsharedpreferencechanged function.

it work need reload preferences screen see efect. there way avoid , reload values instantly?

my guess can't way, because first commit needs ended before changing else.

this common requirement unfulfilled i'm afraid. either have reload screen hacks setpreferencesscreen(null); or (better) register sharedpreferenceschanged listener , update prefs manually. see : update preferences values after changing them programatically

in case should add if clauses in existing sharedpreferenceschanged listener "hear" change in "some_pref" preference , update displayed value manually.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -