List of usage examples for android.preference Preference getContext
public Context getContext()
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 w w w .j a v a 2s . 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: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.// www . j a v a2 s . c om * * @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:com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment.java
static void updateCustomInputStylesSummary(final Preference pref) { // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}. SubtypeLocaleUtils.init(pref.getContext()); final Resources res = pref.getContext().getResources(); final SharedPreferences prefs = pref.getSharedPreferences(); final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res); final InputMethodSubtype[] subtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype); final ArrayList<String> subtypeNames = new ArrayList<>(); for (final InputMethodSubtype subtype : subtypes) { subtypeNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)); }// w w w .j av a 2s . c o m // TODO: A delimiter of custom input styles should be localized. pref.setSummary(TextUtils.join(", ", subtypeNames)); }
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.// w ww . ja va 2s . co 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 .java 2 s .co 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.// w w w.j ava 2s .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.// w w w . ja v a 2s . c om * * @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: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.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: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 ww w .j a va2s . 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)); } }