Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextInputLayout not showing error message after clearing

I am using TextInputLayout from com.android.support:design:23.3.0

When I first apply an error it is shown correctly.

mInputPassword.setError(getString(R.string.error_invalid_password));
mInputEmail.setError(getString(R.string.error_field_required));

enter image description here

On the next login attempt I clear the error.

mInputEmail.setError(null);
mInputPassword.setError(null);

Then I run the validation and set the error again using the same code as above but this time the red line is applied but the error text is missing. enter image description here

Anyone have any ideas on why this might be happening or have experienced similar situations?

I saw something similar reported here but it is for an older version of the design library and don't know if it is still a issue in the verison I am using,

like image 288
J Whitfield Avatar asked Apr 28 '16 10:04

J Whitfield


1 Answers

You simply has to do these steps:

setErrorEnabled(true);
setError("error");

for clearing:

setError(null);
setErrorEnabled(false);

repeat the first step to set a new error. setError(null) clears the error message and icon, so I think the view to show is simply gone and setErrorEnabled(false) will reset it.

like image 187
Opiatefuchs Avatar answered Oct 16 '22 19:10

Opiatefuchs