仅文本输入机器人的EditText [英] Text Only Input EditText android
本文介绍了仅文本输入机器人的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从输入任何特殊字符或数字为编辑文本restric用户,但编程它应该允许。
I want to restric user from entering any special character or number into edit text, but programmatically it should allow.
我知道我可以让的inputType =TEXT
,但它仅与softkeyboard交易。我认为它可以与TextWatcher被achived,但我不能够凝胶evrything。谁能帮助?
I know I can make inputType="text"
but it deals only with the softkeyboard. I think it can be achived with TextWatcher, but I am not able to gel evrything. Can anyone help ?
推荐答案
您可以通过下面的过滤器输入文本,
You can filter input text by following ,
etTwamboxName.setFilters(new InputFilter[] { new InputFilter() {
public CharSequence filter(CharSequence src, int start, int end,
Spanned dst, int dstart, int dend) {
Log.e("", "===> " + src);
if (src.equals("")) { // for backspace
return src;
}
if (src.toString().matches("[a-zA-Z ]+.")) {
return src;
}
return "";
}
} });
这篇关于仅文本输入机器人的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文