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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -