本文介绍了键盘建议导致机器人EditText.setError(的一部分)消息到不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用 edittext.setError(输入注释)
在Android中,它工作正常,直到键盘的建议上来,误差会高于推的EditText
后,它不会显示整个错误消息。
为什么这样做呢?
解决方案
因此,当文字被更改,应该消失。我不知道为什么这种情况不会发生在你的案件。
也应该清零错误信息为空,所以一招可以是:
的EditText =(EditText上)findViewById(R.id.foo); //添加下面这行
edittext.addTextChangedListener(新TextWatcher(){
公共无效afterTextChanged(编辑S){}
公共无效beforeTextChanged(CharSequence中,诠释开始,诠释计数,之后INT){}
公共无效onTextChanged(CharSequence中,诠释开始,诠释之前,诠释计数){
如果(S =空&安培;!&安培; s.length()大于0&安培;&安培;!edittext.getErrorMessage()=空){
edittext.setErrorMessage(空);
}
}
});
When I'm using edittext.setError("enter a comment")
in android, it works fine until the keyboard suggestions come up and the error gets pushed above the edittext
, after which it does not display the whole error message.
Why is it doing this?
解决方案
So when the text is changed it should be gone. I don't know why this doesn't happen in your case.
It should also be cleared when error message is null, so one trick could be:
edittext = (EditText)findViewById(R.id.foo); // add below this line
edittext.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count){
if(s != null && s.length() > 0 && edittext.getErrorMessage() != null) {
edittext.setErrorMessage(null);
}
}
});
这篇关于键盘建议导致机器人EditText.setError(的一部分)消息到不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!