How to show all edittext error messages at once in

2019-07-08 21:51发布

I have two EditTexts and I am applying validations on them. If the validations fail, I want to show all the error messages at once. At a time, I'm getting only one error message which is fixed to the bottom EditText field. How to show all the EditText error messages at once?? I am using the following code:

 if(uname.matches(""))
              username.setError("Email is required");

if(pwd.matches(""))
            password.setError("Password is required");

my screen shot is:

enter image description here

1条回答
爷的心禁止访问
2楼-- · 2019-07-08 22:26

You have to setError(null) in else condition.

if(uname.matches(""))
              username.setError("Email is required");
else
              username.setError(null);

if(pwd.matches(""))
            password.setError("Password is required");
else
              password.setError(null);
查看更多
登录 后发表回答