I try to change CheckBox background after user change its state to Checked. Code below doesn\'t work quite well. If i click unchecked checkbox
For it to change when checked you need to attach an OnCheckChangedListener. Then place the above code inside that.
CheckBox tmpChkBox = (CheckBox) findViewById(view.getId());
tmpChkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
buttonView.setBackgroundColor(Color.BLUE);
} else {
buttonView.setBackgroundColor(Color.RED);
}
}
});