项目中经常遇到EditText需要限制输入的情况,虽然EditText本身inputType自带了很多类型,如果遇到需要自定义输入限制时可以使用InputFilter接口,
例如需要限制输入表情符号,可以这样:
1 |
|
然后使用addInputFilter添加到EditText中即可。
All problems in computer science can be solved by another level of indirection.
项目中经常遇到EditText需要限制输入的情况,虽然EditText本身inputType自带了很多类型,如果遇到需要自定义输入限制时可以使用InputFilter接口,
例如需要限制输入表情符号,可以这样:
1 |
|
然后使用addInputFilter添加到EditText中即可。