EditText not clear error message

2019-08-04 04:19发布

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 ?

2条回答
小情绪 Triste *
2楼-- · 2019-08-04 04:49

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.

查看更多
等我变得足够好
3楼-- · 2019-08-04 04:50

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 ().

Screenshot 1

查看更多
登录 后发表回答