I want to make an EditText
box and use TextWatcher
to prevent typing of special characters.
This is for only character and space validation...
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.isLetter(source.charAt(i)) && !Character.isSpaceChar(source.charAt(i)))
return "";
return null;
}
};
myTextView.setFilters(new InputFilter[] { filter });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With