I want to change multiple textView colors through a couple if statements. All of them have different ID's except for the last part of them that ends with "....Price". I have tried just pasting the if statements on all of them but the build fails.
i have made declarations like this.
textView1Price = ("+10.00") textView2Price = ("-10.00") textView3Price = ("0.00")
and the if statements like so.
if (colorID.text.startsWith("-")) {
colorID.setTextColor(Color.RED)
}
if (colorID.text.startsWith("+")) {
colorID.setTextColor(Color.GREEN)
}
if (colorID.text.startsWith("0.00")) {
colorID.text = "_"
colorID.setTextColor(Color.DKGRAY)
I am having trouble figuring out how to connect the declarations to the If statements. I have tried something like this with partial success but can't list more that one declaration.
val colorID = textView1Price
i have also tried to find a way to reference the
text.contains("Price")
but have not been able to. Any help is appreciated. Thanks for your time.
Aucun commentaire:
Enregistrer un commentaire