radio button - check a condition before calling oncheckedchanged listener in android -
i have radio group whom have implemented oncheckedchanged
follows:
radiogroup mradiogroup = (radiogroup) findviewbyid(r.id.radio_grp); mradiogroup.setoncheckedchangelistener(this);
my activity implements oncheckedchangelistener
,
@override public void oncheckedchanged(radiogroup group, int checkedid) { switch (group.getid()) { case r.id.radio_grp: if (my condition true) { log.d(tag, "want change radio group's checked button if code reaches here."); } else { log.d(tag, "do not want change radio group's checked button if code reaches here."); } break; default: break; } }
now whenever user clicks radio button, fires code inside oncheckedchanged , checked radio button clicked user. want check if "my condition true" should change radio button selection , not change if condition false.
can suggest should achieve this?
thanks!
ps: not able think should write in "subject" of question if can conclude subject, please edit it.
pps: tried resetting radio group's state via group.check(r.id.last_selected_id);
throw stackoverflow exception code stuck in never ending loop.
Comments
Post a Comment