Accents EditText Android

2

Someone there knows how I can and can do the following, in my EditText I wanted the user could not put accents.

Should it be better to treat the text and remove it after typing?

    
asked by anonymous 06.05.2015 / 15:24

1 answer

1

Solution 1 ( InputFilter )

You can use InputFilter for this purpose, with the implementation something like this:

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++) {
            // Não tenho certeza se esse método "Character.isLetterOrDigit" restringe todos os acentos como você espera, mas no seu caso você pode substitui-lo pelo seu método.
            if (!Character.isLetterOrDigit(source.charAt(i))) {
                return "";
            }
        }
        return null;
    }
};
editText.setFilters(new InputFilter[] { filter });

Solution 2 ( digits of EditText )

Another possibility is you inform which entries you allow, in the digits attribute% of EditText , and may be something like this:

<EditText
    android:inputType="text"
    android:digits="0123456789qwertzuiopasdfghjklyxcvbnm" />
    
06.05.2015 / 15:46