I'm trying to set the background colour of a check box when it has been checked then and if it is unchecked then to remove that colour.
Can anybody help me find the Id of the checkbox then to check if it is checked. I have set in my XML sheet android:onClick="handleCheckBoxClick"
For you to get an idea of how it looks I have roughly 25 check boxes. which I need the same doing to them when they are pressed.
Is it possible to have one block of code or would it need to be repeated for each checkbox?
EDIT: Forgot to mention this is within a fragment (if that makes any difference)
public void handleCheckBoxClick(View view) {
int chkID = view.getId();
if (){
}else{
}
//find which checkbox was checked then get its id
/*
* if checked then
* change background colour to blue
* if unchecked then
* remove background colour
*
*/
}
The colour part i'll try myself as do need to learn .