Hello, I'm using a CheckBox and I would like it if it was Checked, it becomes visible a Layout. I'm using the code below and it only works for when it's clicked, but I already want to check it out. I tried to get the code from within the .setOnCheckedChangeListener, but it did not work. Does anyone know what might be happening? Thank you
cbx22.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (cbx22.isChecked()) {
layhorario.setVisibility(View.VISIBLE);
} else {
layhorario.setVisibility(View.GONE);
}
}
});