android - How to re-run code from my if if else statement -


i have 4 buttons answers , eliminate 1 of buttons. have way of randomly choosing button , using if statement determine if selected button in fact actual answer not want button eliminated. problem have there 1 in 4 chance of button being chosen , if chosen want process start again until if condition false.

    private int[] myint;     public static final random rgenerator = new random(); public void onclickeliminate(view view) {      resources res = getresources();     myint = res.getintarray(r.array.ansarray);     int ans = myint[rgenerator.nextint(myint.length)];      button button = (button) findviewbyid(ans);     charsequence message = button.gettext().tostring();      textview textview = (textview) findviewbyid(r.id.correct);     charsequence answer = textview.gettext().tostring();      if (message.equals(answer)) {     // here need above process run again         log.i(logtag, "keep button");     } else {          button.setvisibility(view.gone);         log.i(logtag, "button gone");     } } 

i realise need run on thread looking @ basic functionality @ present. there out there can please. kind regards, derek

ps: have tried use loops either ineffective or infinite. thought using random value "message" should change @ stage.

try this:

boolean myprocess = true;  while(myprocess){     if (message.equals(answer)) {        // here need above process run again        log.i(logtag, "keep button");    } else {          myprocess = false;         button.setvisibility(view.gone);         log.i(logtag, "button gone");    } } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -