I am using EditText with TextInputLayout. This is the code, that I am using to display error.
private boolean validateEmail() {
String email = inputEmail.getText().toString().trim();
if (email.isEmpty() || !isValidEmail(email)) {
inputLayoutEmail.setErrorEnabled(true);
inputLayoutEmail.setError(getString(R.string.err_msg_email));
requestFocus(inputEmail);
return false;
} else {
inputLayoutEmail.setErrorEnabled(false);
}
return true;
}
I am calling this method in edittext's textwatcher like in this link http://www.androidhive.info/2015/09/android-material-design-floating-labels-for-edittext/
Once I entered a valid input then clear that ,it will show error message as expected,But it wont work if i enter the text again and then clear it again.ie.It is not showing any error message.
I am using compile 'com.android.support:design:23.1.0'
library.
inputLayoutEmail.setErrorEnabled(true);
is calling but error is not displaying. What might be the problem? How I can solve this?
In your layout file, ensure you have layout_height="wrap_content"
for the TextInputLayout
instead of a dimension. This was causing the issue for me.