When check box inside a layout is checked the backround of layout should be white and if check box is unchecked layout should be black.is this possible in android??
Asked
Active
Viewed 997 times
3 Answers
1
U try wid `
checkBox.setOnClickListener(new OnClickListner(){
layout = finViewById(R.Layout.LinearLayout); layout.setBackgroundColor(//color)
})
not syntactically right..`

ngesh
- 13,398
- 4
- 44
- 60
1
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
youtLayout.setBackgroundColor(Color.WHITE);
}else{
youtLayout.setBackgroundColor(Color.BLACK);
}
}
});

Labeeb Panampullan
- 34,521
- 28
- 94
- 112
0
Some example code that should get you started:
if(checkbox.isChecked())
findViewById(R.id.background).setBackgroundColor(Color.WHITE);
else
findViewById(R.id.background).setBackgroundColor(Color.BLACK);

joey
- 578
- 4
- 10