List of usage examples for android.preference Preference getKey
public String getKey()
From source file:org.projectbuendia.client.ui.SettingsActivity.java
/** * Shows a preference's string value on its summary line (below the title * of the preference), and keep the summary updated when the value changes. * * @see #sListener/*from ww w.j a v a 2 s .c o m*/ */ private static void showValueAsSummary(Preference pref) { // Set the listener to watch for value changes. pref.setOnPreferenceChangeListener(sListener); // Trigger the listener immediately with the preference's current value. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(pref.getContext()); sListener.onPreferenceChange(pref, prefs.getAll().get(pref.getKey())); }
From source file:org.symptomcheck.capstone.ui.SettingsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of txtMedicineName below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference.// ww w . ja v a 2 s . c o m * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. Object value; if (preference.getKey().equals(UserPreferencesManager.KEY_SYNC_ONLY_WIFI)) { value = PreferenceManager.getDefaultSharedPreferences(preference.getContext()) .getBoolean(preference.getKey(), false); } else { value = PreferenceManager.getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), ""); } sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value); }
From source file:com.concavenp.nanodegree.popularmovies.SettingsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference./* w ww . ja v a2 s. c o m*/ * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(Preference preference, String defaultValue) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), defaultValue)); }
From source file:org.segin.ttleditor.SettingsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference./*from w w w. j a v a 2 s . c o m*/ * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger thelistener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), "")); }
From source file:com.ofalvai.bpinfo.ui.settings.SettingsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference./*from ww w. ja v a 2 s. c o m*/ * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(@NonNull Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), "")); }
From source file:com.example.android.DroidCafeWithSettings.SettingsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference.// ww w . j ava 2 s . c om * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), "")); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.settings.PrefsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference.//from w ww.j a v a 2 s . co m * * @see #sBindPreferenceSummaryToValueListener */ public static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), "")); }
From source file:com.wanderfar.expander.Settings.SettingsActivity.java
private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), "")); }
From source file:de.domjos.schooltools.activities.SettingsActivity.java
private static void bindPreferenceSummaryToValueSet(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager.getDefaultSharedPreferences(preference.getContext()) .getStringSet(preference.getKey(), new HashSet<String>())); }
From source file:com.xengar.android.englishverbs.ui.SettingsActivity.java
/** * Binds a preference's summary to its value. More specifically, when the * preference's value is changed, its summary (line of text below the * preference title) is updated to reflect the value. The summary is also * immediately updated upon calling this method. The exact display format is * dependent on the type of preference.//from www . j a v a 2 s . c o m * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference' current value. if (preference instanceof ListPreference || preference instanceof EditTextPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), "")); } else if (preference instanceof SwitchPreference || preference instanceof CheckBoxPreference) { sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()).getBoolean(preference.getKey(), true)); } }