SetError not cleared after typing text into edittext in Android
EditText setError
the message is not cleared when I enter text into the edittext in the device. But its work in the emulator.
I used below code in edittext xml code:
android:inputType="textNoSuggestions"
Please help me.
+3
user4066399
source
to share
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
Furqan
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
Haresh Chhelana
source
to share