Code example for EditTextPreference

Methods: setDefaultValuesetDependencysetEnabledsetKeysetTitle, getEditText, setDialogTitle

0
		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;
			} 
		}); 
		notifyInterval.getEditText().setMaxLines(1);
		notificationPreferences.addPreference(notifyInterval);
		notifyInterval.setSummary(formatSummary("notifyinterval", "----"));
		notifyInterval.setEnabled(isInterval);
		notifyInterval.setDependency(notifyEnabled.getKey());
 
		TimePickerPreference notifyIntervalTime = new TimePickerPreference(this);
		notifyIntervalTime.setKey("notifyintervaltime");
		notifyIntervalTime.setTitle("Interval Start Time");
		notifyIntervalTime.setDialogTitle("Interval Start Time");