![](/img/trans.png)
[英]how I can change the color of the TextView while the user is typing the text in the EditText
[英]how to change textview color upon entering something in edittext
如果这是一个密码检查器,那么可能已经有一个用于此的库。 否则,您可以使用 addTextChangedListener() 来侦听 EditText 中的文本更改,然后调用 setTextColor() 来更改 EditText。
在 OnTextChanged 方法中的 addTextChangedListener() 之后添加这个并可以设置颜色
if (charSequence.toString().contains("^[0-9]*$")) {//numbers
}
if (charSequence.toString().contains("^[a-z]*$")){//lower case
}
if (charSequence.toString().contains("^[A-Z]*$")){//uppercase
}
if (charSequence.toString().length()==9){//ten characters
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.