android - Set CheckBox enabled if togglebutton is checked -
i created togglebutton push notification service (if button checked, notifications reveived). want, when check button, checkbox checkbox. if button isn't check, checkbox should disabled.
i used code, not work. when togglebutton off, checkbox disabled. 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); }
i not sure trying implement enable/disable checkbox
on toggle
change, should that:
toggle.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { pushbots.sharedinstance().togglenotifications(ischecked); chicken.setenabled(ischecked); } });
and don't need part:
if (toggle.ischecked()) { chicken.setenabled(true); }
Comments
Post a Comment