java - Inner class - final variable can't be looped? -
i'm trying make loop gives each button method parameter dependent on button is. keep getting error:
i not final variable - must if nested in inner class.
for (int = 0; < 14; i++) { buttons[i].setonclicklistener(new button.onclicklistener() { public void onclick(view v) { // issue value here move.makemove(move.cups.get(i); updatebuttons(); } }); currentcup = nextcup; }
try way:
for (int = 0; < 14; i++) { final int currenti = i; buttons[i].setonclicklistener(new button.onclicklistener() { public void onclick(view v) { // issue value here move.makemove(move.cups.get(currenti); updatebuttons(); } }); currentcup = nextcup; }
Comments
Post a Comment