My app is based on the fragments. When i go to the next fragment and return back, than I try to clear my field error message field.setError(null)
in onStart()
method, but this field have null reference on the error message (field.getError()
) . But after onStart()
method there appeared reference on the error message. When EditText
takes reference on the error message ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Fixed problem with the following method:
name.post(new Runnable() {
@Override
public void run() {
name.setError(null);
}
});
Method post call, when view state has been restored, so all works properly.
回答2:
I met the same problem, but later I refer to the Android Studio automatically generated file, found to have a different way, this way will it setError message is displayed in the EditText last icon, and this error message when you are changing input will automatically disappear.The editText must perform the editText. RequestFocus ();Then execute setError ().