I want the output to be green if the counter is 20 or above and red if it is below 20. this is the code I have so far and it isnt working.
add1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub counter = counter += 1; if (counter >= 20) { display.setText(Color.GREEN); //display.setText("" + counter); } else if (counter < 20) { display.setTextColor(Color.RED); //display.setText("" + counter); } display.setText("" + counter); } }); sub1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub counter = counter -= 1; if (counter >= 20) { display.setText(Color.GREEN); //display.setText("" + counter); } else if (counter < 20){ display.setTextColor(Color.RED); //display.setText("" + counter); } display.setText("" + counter); } });
display.setTextColor(Color.GREEN);instead ofdisplay.setText(Color.GREEN);?