I want change radio button color depending on it's id.
How can I do that?
I want change radio button color depending on it's id.
How can I do that?
Set to the radio buttons the same attribute (in the UI layout)
android:onClick="onRadioButtonClicked"
and in the code you can change the colors.
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radio_1:
if (checked)
// change color
break;
case R.id.radio_2:
if (checked)
// change color
break;
}
}
Have a look: