EditTextPreference getEditText - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getEditText, setText
    assertNotNull(preference.getEditText());
  } 
 
  @Test 
  public void testSetText() { 
    preference.setText(SOME_TEXT);
    assertThat((String) preference.getEditText().getText().toString()).isEqualTo(SOME_TEXT);
  } 
 
} 
8
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:setDialogTitle, getEditText, setDefaultValue, setKey, setSummary
This code example shows how to use the following methods:getEditText, setText
	private void setPreferenceValue(Method getter, Preference p) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
		Object ret = getter.invoke(object, (Object[])null);
		if(ret != null) {
			if(p.getClass().equals(EditTextPreference.class)) {
				EditTextPreference etp = (EditTextPreference)p;
				etp.setText(ret.toString());
				if((etp.getEditText().getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) == 0)
					updatePreferenceSummary(etp, ret.toString());
			} else if(p.getClass().equals(CheckBoxPreference.class)) {
				((CheckBoxPreference)p).setChecked((Boolean)ret);
			} else if(p.getClass().equals(ListPreference.class)) {
				ListPreference lp = (ListPreference)p;
				lp.setValue(ret.toString());
				updatePreferenceSummary(lp, ret.toString());
			} 
		} 
	} 
	 
	private void updatePrefs() { 
 
6
CodeRank
This code example shows how to use the following methods:setDialogTitle, getEditText, setDefaultValue, setKey, setOnPreferenceChangeListener
This code example shows how to use the following methods:setDialogTitle, getEditText, setKey, setTitle
This code example shows how to use the following methods:getEditText, setDefaultValue, setKey, setOnPreferenceChangeListener, setDialogTitle
This code example shows how to use the following methods:setDialogTitle, getEditText, setDefaultValue, setDependency, setEnabled
		notificationPreferences.addPreference(notifyTime);
		notifyTime.setDependency(notifyEnabled.getKey());
		notifyTime.setEnabled(isSetTime);
		notifyTime.setSummary(formatSummary("notifytime",notifyTime.getTime()));
 
		EditTextPreference notifyInterval = new EditTextPreference(this);
		notifyInterval.setKey("notifyinterval");
		notifyInterval.setTitle("Notification Interval");
		notifyInterval.setDialogTitle("Notification Interval (in hours)");
		notifyInterval.setDefaultValue("24");
		notifyInterval.getEditText().setKeyListener(new NumberKeyListener() {
			@Override 
			protected char[] getAcceptedChars() { 
				char[] numberChars = {'1','2','3','4','5','6','7','8','9','0'};
				return numberChars;
			} 
 
			@Override 
			public int getInputType() { 
				return InputType.TYPE_NUMBER_FLAG_DECIMAL;

5
CodeRank
This code example shows how to use the following methods:getEditText, setDefaultValue, setKey, setOnPreferenceChangeListener, setDialogTitle
This code example shows how to use the following methods:getEditText, getText, getSummary

Related EditTextPreference getEditText Questions & Answers:

getEditText Method Overview
Returns the EditText widget that will be shown in the dialog.
See Code Examples for other Android EditTextPreference Methods: