Simultaneously display error on two `EditTexts` in android

advertisements

I'm working on a from in android. It has a two EditTexts, one for name and the other for email. I want that when both the fields are blank, the warning should appear on both fields. Not only the "!" mark encircled in red but also the message I type in:

Name.setError("Customer's Name is Required!"); Email.setError("Customer's Email is Required!");

Currently it displays the message only on the field which has focus. How to show the message on fields which are not focused?


try this way

if (Name.getText().toString().equals("")){
                    Name.setError("Customer's Name is Required!");
                }
 if (Email.getText().toString().equals("")){
                    Email.setError("Customer's Email is Required!");
                }