机器人的EditText输入过滤器应该接受的空间,人物和放大器;数 [英] android edittext inputfilter should accept space,character & number

查看:146
本文介绍了机器人的EditText输入过滤器应该接受的空间,人物和放大器;数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

street = (EditText) findViewById(R.id.street);
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)) || !Character.isSpaceChar(source.charAt(i))) { 
                 return "";     
             }     
        }
        return null;   
    }  
};
street.setFilters(new InputFilter[] { filter });

我的EditText能够过滤字符和放大器;虚拟键盘上的数字,但不采取空格字符.. plz帮助

my edittext is able to filter character & number on the virtual keyboard but not taking the space character.. plz help

推荐答案

而不是'||'我换成'和;&放大器;'并得到了答案......

instead of '||' i replaced with '&&' and got the answer....

这篇关于机器人的EditText输入过滤器应该接受的空间,人物和放大器;数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆