android - How will i create a loop inside a button click -


i have 1 button , text view . want display number 0-5 in text view when each time click on button.

int index = 2;                      switch (index) {                         case 0:                             // if using index 0, set text index 1 text , change index 1                             index = 1;                             line2.settext(0);                             break;                         case 1:                             index = 2;                             line2.settext(1);                             break;                         case 2:                             index = 0;                             line2.settext(2);                             break;                     } 

i had tried of examples available on internet,but not changing value. please me figure out.

thanks in advance.

int mcounter = 0; 

on onclick() of button:

if(mcounter>4){      mcounter=0;  } mcounter++; txtinfo.settext(""+mcounter); 

hope you.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -