Input filter (space not allowed) for EditText

This example which prevent the user to enter blank space in edit text field in Android app 

EditText.setFilters(new InputFilter[] { filter });


InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (Character.isSpaceChar(source.charAt(i))) {
return "";
}
}
return null;
}
}

Comments

Post a Comment

Popular posts from this blog

Android Versions details

English - Formal and Informal words