Android Preference.OnPreferenceChangeListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Preference.OnPreferenceChangeListener class.

This code example shows how to use the following methods:onPreferenceChange
        // Set the listener to watch for value changes. 
        preference.setOnPreferenceChangeListener(sSetSummaryListener);
 
        // Trigger the listener immediately with the preference's current value. 
        sSetSummaryListener
                .onPreferenceChange(preference, prefs.getString(preference.getKey(), ""));
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getEditText, getText, getOnPreferenceChangeListener, setOnPreferenceChangeListener, onPreferenceChange
public class MyPrefScreen extends PreferenceActivity {
	static final LogCategory log = new LogCategory("MyPrefScreen");
	 
	void initNumberEdit(String key,int min,int max,int def,int desc_string_id){
		EditTextPreference pref = (EditTextPreference)findPreference(key);
		EditText et = pref.getEditText();
		et.setHorizontallyScrolling(true);
		et.setSingleLine(true);
		et.setInputType(InputType.TYPE_CLASS_NUMBER);
 
		final int _min = min;
		final int _max = max;
		final int _def = def;
		final int _desc_string_id = desc_string_id;
		 
		pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			@Override 
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				if(!MyApp.checkInteger(newValue,_min,_max)){
					Toast.makeText(MyPrefScreen.this,R.string.number_range_error,Toast.LENGTH_SHORT).show();

6
CodeRank
This code example shows how to use the following methods:onPreferenceChange
      ((ListPreference) preference).setEntries(options);
    } 
    if (values != null) {
      ((ListPreference) preference).setEntryValues(values);
    } 
    preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override 
      public boolean onPreferenceChange(Preference pref, Object newValue) {
        updatePreferenceSummary(pref, options, values, summaryId, newValue,summarizer);
        if (listener != null) {
          listener.onPreferenceChange(pref, newValue);
        } 
        return true; 
      } 
    }); 
    updatePreferenceSummary(preference, options, values, summaryId, value, summarizer);
    if (listener != null) {
      listener.onPreferenceChange(preference, value);
    } 
     

4
CodeRank
This code example shows how to use the following methods:onPreferenceChange
      ((ListPreference) preference).setEntries(options);
    } 
    if (values != null) {
      ((ListPreference) preference).setEntryValues(values);
    } 
    preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override 
      public boolean onPreferenceChange(Preference pref, Object newValue) {
        updatePreferenceSummary(pref, options, values, summaryId, (String) newValue);
        if (listener != null) {
          listener.onPreferenceChange(pref, newValue);
        } 
        return true; 
      } 
    }); 
    updatePreferenceSummary(preference, options, values, summaryId, value);
    if (listener != null) {
      listener.onPreferenceChange(preference, value);
    } 
  } 

4
CodeRank
This code example shows how to use the following methods:onPreferenceChange
		preference
				.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
 
		// Trigger the listener immediately with the preference's 
		// current value. 
		sBindPreferenceSummaryToValueListener.onPreferenceChange(
				preference,
				PreferenceManager.getDefaultSharedPreferences(
						preference.getContext()).getString(preference.getKey(),
						"")); 
	} 
 
	/** 
	 * This fragment shows general preferences only. It is used when the 
	 * activity is showing a two-pane settings UI. 
	 */ 
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	public static class GeneralPreferenceFragment extends PreferenceFragment {
		@Override 
		public void onCreate(Bundle savedInstanceState) {
3
CodeRank
This code example shows how to use the following methods:onPreferenceChange
    preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override 
      public boolean onPreferenceChange(Preference pref, Object newValue) {
        updatePreferenceSummary(pref, options, values, summaryId, (String) newValue);
        if (listener != null) {
          listener.onPreferenceChange(pref, newValue);
        } 
        return true; 
      } 
    }); 
    updatePreferenceSummary(preference, options, values, summaryId, value);
    if (listener != null) {
      listener.onPreferenceChange(preference, value);
    } 
  } 
 
  /** 
   * Updates a preference when a stored value changes. 
   *  
   * @param preference the preference 
4
CodeRank
This code example shows how to use the following methods:onPreferenceChange
    preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override 
      public boolean onPreferenceChange(Preference pref, Object newValue) {
        updatePreferenceSummary(pref, options, values, summaryId, (String) newValue);
        if (listener != null) {
          listener.onPreferenceChange(pref, newValue);
        } 
        return true; 
      } 
    }); 
    updatePreferenceSummary(preference, options, values, summaryId, value);
    if (listener != null) {
      listener.onPreferenceChange(preference, value);
    } 
  } 
 
  /** 
   * Updates a preference when a stored value changes. 
   *  
   * @param preference the preference 
4
CodeRank

Related Android Preference.OnPreferenceChangeListener Questions & Answers:

See Code Examples for Android Preference.OnPreferenceChangeListener Methods: