Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
520 views
in Technique[技术] by (71.8m points)

android - EditText setError message does not clear after input

Ok so I only have a EditText field and a button, which when pressed triggers an AsyncTask.

EditText playerName = (EditText)findViewById(R.id.playerEditText);

if(playerName.getText().toString().length() == 0 )
    playerName.setError("Player name is required!");
else {
    // do async task
}

The problem is that the error message seems to stay up even after when I input valid text to search. Is there a way to remove the error as soon as the EditText is not empty?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In your else bracket, put playerName.setError(null), which will clear the error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...