TextInputLayout set error without message?

Is it possible to fix an error in the text input layout without showing an error message (I'm already doing it elsewhere)?

textinputlayout.setError(""); 

will not work unfortunately.

I need the textInputLayout to change the line color to red, but I need to do this programmatically. Thanks you

+9
android android-textinputlayout
source share
2 answers

You can hide the layout with an error, for example like this:

 textinputlayout.setError(" "); if (textinputlayout.getChildCount() == 2) { textinputlayout.getChildAt(1).setVisibility(View.GONE); } 
+3
source share

Hope it's not too late, but the code is setError :

 if (!mErrorEnabled) { if (TextUtils.isEmpty(error)) { // If error isn't enabled, and the error is empty, just return return; } } 

this means a simple workaround would be:

textinputlayout.setError(" ");

Please keep in mind that this will make the TextView with the error message visible - so the TextInputLayout will be higher even if it is empty

since this goes through a not-so-well-thought-out case of processing an empty request for an error message.

0
source share

All Articles