dimanche 24 avril 2016

Can't compare string turned into integer java

So, I need to change my textView color to red if it's more than 0 and to green if it's less than 0, but I can't write if statement properly, because textView is a string, but I've changed it to int.

textView.setText(textView + "");


        if(textView > 0) {
            textView.setTextColor(this.getResources().getColor(R.color.colorAccent));
        }
        else if (textView < 0){
            textView.setTextColor(this.getResources().getColor(R.color.colorPrimary));
         }
        else {
            textView.setTextColor(this.getResources().getColor(R.color.colorPrimaryDark));

    }

Aucun commentaire:

Enregistrer un commentaire