Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid MultiSelectListPreference uncheck does not fire SharedPreferenceChanged
    primarykey
    data
    text
    <p>I'm using a <a href="http://developer.android.com/reference/android/preference/MultiSelectListPreference.html" rel="nofollow">MultiSelectListPreference</a> with the following properties..</p> <pre><code>&lt;MultiSelectListPreference android:key="shop_list" android:entries="@array/shop_titles" android:entryValues="@array/shop_values" android:title="@string/pref_title_shops" android:dialogTitle="@string/pref_title_shops" android:defaultValue="@array/shop_values" android:summary="Choose where you hunt" /&gt; </code></pre> <p>The preferences are inside a static <code>PreferenceFragment</code>, inside a common <code>Activity</code>. I m registering and unregistering the listener for the <code>SharedPreferenceChanged</code> event on the <code>onPause</code> and <code>onResume</code> of the <code>PreferenceFragment</code>.</p> <p>code excerpt: </p> <pre><code>public class AgentSettingsActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); } public static class SettingsFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Utils.Log("onCreate"); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.pref_general); } @Override public void onResume() { Utils.Log("onResume"); super.onResume(); try { Utils.Log("Add pref listeners and try set summary"); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); } catch (Exception e) { Utils.Log("Pref not found"); } } @Override public void onPause() { super.onPause(); Utils.Log("onPause"); // Unregister the listener whenever a key changes getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Utils.Log("onPreferenceChange, key : " + key); } } } </code></pre> <p>When i check an option, the event fires everytime <strong>until</strong> I start unchecking them.. Then the listener stops getting called. Any ideas what I m missing here? Does this have smth to the with the way i use the Fragment / Activity ?</p> <p>NOTE: I should also add that I have a ListPreference which continues to work even after the MultiSelectListPref stops responding properly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload