I have a radiogroup containing several radiobuttons whose background color is grey. When I click on a radiobutton I would need the clicked one to change background color to black, while others would keep the grey background. I know I can set OnCheckedChangeListeners for all radiobuttons like this:
if(checked) then setBackGroundColor to black;
else setBackGroundColor to grey;
but is there any more efficient way to do that? Like write just one OnCheckedChangeListener for the whole group
Create a selector -> drawable/radio_selector.xml
And in the RadioButton view add
This works on api 21+ If you are using a lower minimum api you will need to set buttonTint in a style
and add this instead to your RadionButton