java - Using Do While loop take input until user get 1 -
i want multiple input until user can't 1. not work properly. in case, can take multiple edit text box, or not? please tell me.
textview tv; edittext et; button b; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.evenodd2); tv= (textview) findviewbyid(r.id.textviewevenodda); et= (edittext) findviewbyid(r.id.edittextevenodd); b= (button) findviewbyid(r.id.buttonevenodda); b.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { string a1; int num; { a1=et.gettext().tostring(); num=integer.parseint(a1); if (num < 1) tv.settext("wrong input"); if (num > 1 && num % 2 == 0) { tv.settext("value is: "+num / 2); } else { tv.settext("value :"+num); } } while (num != 1); tv.settext("thank you"); } }); }}
you wouldn't use loop here. you'd processing once every time user presses button. loop getting input how console work, not how gui driven program reacts.
Comments
Post a Comment