How to show all edittext error messages at once in android?

馋奶兔 提交于 2019-12-12 22:14:24

问题


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:


回答1:


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);


来源:https://stackoverflow.com/questions/31963271/how-to-show-all-edittext-error-messages-at-once-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!