setError
Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed
in a popup when the TextView has focus. The icon and error message
will be reset to null when any key events cause changes to the
TextView's text. If the error is null, the error message and icon will
be cleared.
So when the text is changed it should be gone. I don't know why this doesn't happen in your case.
It should also be cleared when error message is null, so one trick could be:
edittext = (EditText)findViewById(R.id.foo); // add below this line
edittext.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count){
if(s != null && s.length() > 0 && edittext.getErrorMessage() != null) {
edittext.setErrorMessage(null);
}
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…