Home » Android » java – TextInputLayout "setError(null)" before "setErrorEnabled(false)" necessary?-Exceptionshub

java – TextInputLayout "setError(null)" before "setErrorEnabled(false)" necessary?-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment


Is it necessary to call setError(null) before setErrorEnable(false)? Why? I don’t see the difference but I see many people do that.

How to&Answers:

There is no need to call both of them. When you set an error for a TextInputLayout at the first time, it’s height increase a little under it’s EditText field for showing that error.

If you use setError(null) just the error text will delete, but if you use setErrorEnable(false) both error text and extra space will delete(note that if you have set a helper for TextInputLayout, the error simply replace with the helper text and doesn’t add an extra space so you don’t see any difference between this two methods).