How to exclude special characters from android keypad for EditText
If you want to add spaces you can give space after the last digit.
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 "
try to add the digits parameter to your editText:
android:digits="abcde.....012345789"
Use the filter for that. Here I am adding the code for filter.
EditText etName = (EditText)findViewById(R.id.etName);
InputFilter filter = new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (!Character.isLetterOrDigit(source.charAt(i))) {
return "";
}
}
return null;
}
};
etName.setFilters(new InputFilter[]{filter});