由网友(帅死的骆驼比马大)分享简介:我要限制的字符为0-9,AZ,AZ只有空格键。设置inputtype我可以限制为数字,但我想不出输入过滤的方式翻翻文档。I want to restrict the chars to 0-9, a-z, A-Z and spacebar only. Setting inputtype I can limit to...
我要限制的字符为0-9,AZ,AZ只有空格键。设置inputtype我可以限制为数字,但我想不出输入过滤的方式翻翻文档。
I want to restrict the chars to 0-9, a-z, A-Z and spacebar only. Setting inputtype I can limit to digits but I cannot figure out the ways of Inputfilter looking through the docs.
推荐答案
我发现这在另一个论坛。工程就像一个冠军。
I found this on another forum. Works like a champ.
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 });
相关推荐
最新文章