![](/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.