EditText setError() with no message just the icon

Viewed 22784

Currently I have a really simple code that validates EditText fields and when the user hits the button at the end it checks them. It will put errors in all the fields with this:

if (!emailmatcher.matches()) {
    email.setError("Invalid Email");  
}
if (!zipmatcher.matches()) {
    zipcode.setError("Invalid ZipCode");                     
}

My problem that is the keyboard will popup and will move the error bubble to a random place. I was hoping to not have a error bubbles with a message but keep the error icons in invalid EditText fields. I tried inputting setError(null) but that doesn't work. Any Ideas?

5 Answers

This works for me. Now getting error messages pop up open.

public boolean isValid() {
        String email = ediTextEmail.getText().toString();
        String password = ediTextPassword.getText().toString();
        if (TextUtils.isEmpty(email)) {
            ediTextEmail.requestFocus();
            ediTextEmail.setError("Email cannot be blank");
            return false;
        }

        if (!isEmailValid(email)) {
            ediTextEmail.requestFocus();
            ediTextEmail.setError("Enter a valid email id");
            return false;
        }

        if (TextUtils.isEmpty(password)) {
            ediTextPassword.requestFocus();
            ediTextPassword.setError("Password cannot be blank");
            return false;
        }

        mEmail = email;
        mPassword = password;
        return true;
    }

Pop opened even if my focus is on password editText, it will be redirected to email editText.

Related