简体   繁体   中英

how to change textview color upon entering something in edittext

when the user has put something according to written on the enter image description here text I want that text color to change like in this image

If this is a password checker then there is probably already a library for this. Otherwise, you could use addTextChangedListener() to listen for text changes in your EditText then call setTextColor() to change the of the EditText.

after addTextChangedListener() in OnTextChanged method add this and can set color

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
    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM