I'm looking for a way to change the color of text in a Button with onClick. I want the selected button text color to change and the other button's text to revert to the default color. This way (below) seems very inefficient. Is there a better way to go about it? Also, how would I revert to the original color with onClick?
public void onClick(View v) {
switch (v.getId()){
case R.id.button1:
TextView textView1 = (TextView) findViewById(R.id.button1);
textView1.setTextColor(Color.RED);
logLevel = "E";
//Change the rest to default (white)
break;
case R.id.button2:
TextView textView2 = (TextView) findViewById(R.id.button2);
textView2.setTextColor(Color.RED);
logLevel = "W";
//Change the rest to white
break;
case R.id.button3:
TextView textView3 = (TextView) findViewById(R.id.button3);
textView3.setTextColor(Color.RED);
logLevel = "D";
//Change the rest to white
break;
case R.id.button4:
TextView textView4 = (TextView) findViewById(R.id.button4);
textView4.setTextColor(Color.RED);
logLevel = "I";
//Change the rest to white
break;
}
retrieveLog(logLevel);
}