Android EditText setError()删除可绘制的右侧
我有编辑文本 在它的XML中写着:Android EditText setError()删除可绘制的右侧,android,Android,我有编辑文本 在它的XML中写着:android:drawableRight=“@drawable/promotion\u create\u promotion\u plus\u icn” 当setError(“sss”)时,drawableRight会更改 我想在setError(null)thedrawableRight返回为drawable/promotion\u create\u promotion\u plus\u icn XML: 在java中: @覆盖 公共无效后文本已更改(可编
android:drawableRight=“@drawable/promotion\u create\u promotion\u plus\u icn”
当setError(“sss”)
时,drawableRight
会更改
我想在setError(null)
thedrawableRight
返回为drawable/promotion\u create\u promotion\u plus\u icn
XML:
在java中:
@覆盖
公共无效后文本已更改(可编辑){
((EditText)getCurrentFocus()).setError(null);
}
谁能帮我?问题是
设置错误(null)
也会清除图标。
要恢复原始文件,请添加:
您必须使用
TextInputLayout
包装EditText
,并为TextInputLayout
设置错误,而不是EditText
将整个代码粘贴到此处(包括EditText的XML,然后我们看看能做些什么。我不明白你的问题??drawable right缺失或你想忽略它??请澄清一下……你尝试过我的答案吗?请尝试并让我知道它是否对你有帮助。这是一个很好的答案,但不适合我。因为我结束了很多EditText,每个人都有自己的im年龄
@Override public void afterTextChanged(Editable s) {
EditText edit = (EditText) getCurrentFocus();
edit.setError(null);
edit.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.promotion_create_promotion_plus_icn, 0);
}