SetError not cleared after typing text into edittext in Android
2 answers
install and install in . TextWatcher
edittext
setError(null)
afterTextChanged
edittext.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
edittext.setError(null);
}
});
+10
source to share
Check the value on the text observer and set or disable the error after changing the value:
edittext.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (s.toString().trim().length() > 0) {
edittext.setError(null);
} else {
edittext.setError("Value required");
}
}
});
0
source to share