EditText上SETERROR消息确实后输入不明确

问题描述:

好了,所以我只有一个领域的EditText和一个按钮,这时候pressed触发AsyncTask的。

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
}

现在的问题是,该错误消息似乎甚至当我输入有效的文本搜索后熬夜。有没有一种方法能尽快消除误差的EditText上是不是空的?

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?

在你别的支架,把 playerName.setError(空),这将清除错误。

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