EditText not clear error message

ぐ巨炮叔叔 提交于 2019-12-11 09:29:37

问题


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



来源:https://stackoverflow.com/questions/22402842/edittext-not-clear-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!