I created a Togglebutton for my push notification service (if the button is checked, notifications will be reveived). I also want, that when I check the button, a checkbox is checkbox. If the button isn't check, the checkbox should disabled.
I used that code, but it do not work. Only when the togglebutton is off, the checkbox is disabled. But it do not work otherwise.
ToggleButton toggle = (ToggleButton) findViewById(R.id.toogleNotifications);
toggle.setChecked(Pushbots.sharedInstance().isNotificationEnabled());
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Pushbots.sharedInstance().toggleNotifications(isChecked);
chicken.setEnabled(false);
}
});
if (toggle.isChecked()) {
chicken.setEnabled(true);
}
Aucun commentaire:
Enregistrer un commentaire