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 992 times
3 Answers
1
U try wid `
checkBox.setOnClickListener(new OnClickListner(){
layout = finViewById(R.Layout.LinearLayout); layout.setBackgroundColor(//color)
})
not syntactically right..`
ngesh
- 13,241
- 4
- 43
- 59
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
- 33,641
- 28
- 92
- 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