Skip to content

Instantly share code, notes, and snippets.

@oscarito9410
Created February 26, 2020 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarito9410/5e6d223cc6e0b56f7956df1e5f1252f5 to your computer and use it in GitHub Desktop.
Save oscarito9410/5e6d223cc6e0b56f7956df1e5f1252f5 to your computer and use it in GitHub Desktop.
Input filter alphanumeric android
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.isLetterOrDigit(source.charAt(i))) {
return "";
}
}
return null;
}
};
edit.setFilters(new InputFilter[]{filter});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment