Make Button in Android to repeat process inside activity until counter reaches certain number -


i have button in main view checks if users answer correct.

button checkbutton= (button) this.findviewbyid(r.id.checkbutton);      checkbutton.setonclicklistener(new onclicklistener()      {     public void onclick(view v) {                 // action, setting text         }             });  

if button pressed once checks if answer correct, , if button pressed second time want repeat activity e.g. present user question.

onclicklistener inside oncreate method , question generated using switch , unique id (for game difficulty).

what best way set repeat activity until it's been repeated 4 times. thanks

switch (difficulty_level)  {  case difficulty_hard:  //  case difficulty_easy:  //  } 

to me, doesn't sound logic belonging in onclicklistener @ all. listener should register click , call function in activity "handlebuttonclicked" have access fields keep track of number of clicks question, if answer correct , appropiate action is.

the fact onclicklistener set in oncreate says ready used after oncreate. doesn't require oncreate run again.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -