Preference getOnPreferenceChangeListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Preference getOnPreferenceChangeListener method.

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
Experience pair programming with AI  Get Codota for Java
getOnPreferenceChangeListener Method Overview
Returns the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).
See Code Examples for other Android Preference Methods: