我有一个表单,我在其中放置了这样的验证
if( firstName.getText().toString().length() < 3 )
firstName.setError( "First name is required!" );
因此,如果输入的文本小于 3 个字符,我会收到一条错误消息:“需要名字!”,并且我还会在编辑文本。
但是我想要一个 else
来判断输入数据是否正确,这样我就会在 editText 中得到一个绿色图标。我可以为此使用什么属性?
编辑:是否也可以在打字时进行检查,而不是在按下按钮后进行检查?
最佳答案
yourEditText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.youGreenDrawable, 0, 0, 0);
关于android - Edittext 表单验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16875474/