if you are intersted to change the background color of the checkbox (button) use
mcheckbox.setButtonDrawable(R.drawable.someotherbackground);
where someotherbackground is an image in the drawable folder to which background you want your checkbox to be changed
try as below
mcheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
System.out.println("checked" + isChecked);
mcheckbox.setButtonDrawable(R.drawable.imageWhenActive);
System.out.println("app constant is set as "+isChecked);
}
else
{
mcheckbox.setButtonDrawable(R.drawable.imageWheninactive);
System.out.println("app constant is set as "+isChecked);
}
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…