java - A loop that works before but not after -



java - A loop that works before but not after -

i have problem strange. have same code 3 buttons works first , not others. how possible? there can explain me? much. can click buttons (b , c) ones , not twice. what's going on? in first case (button a) works show 1 card , not two.

@suppresslint("recycle") public class gameactivity extends activity { protected view buttona; protected view buttonb; protected view buttonc; protected view buttond; final int randomint1 = 0; final int randomint2 = 0; int = 0; int b = 0; int c = 0; int d = 0; int e = 0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_game); findviewbyid(r.id.a); resources res = getresources(); string[] stringdeck = getresources().getstringarray(r.array.stringdeck); int[] deckdraw = getresources().getintarray(r.array.deckdraw); final hashmap<string, integer> deck = new hashmap<string, integer>(); for(int = 0; < deckdraw.length; i++){ deck.put(stringdeck[i], deckdraw[i]); } final typedarray deck = res.obtaintypedarray(r.array.deckdraw); final viewgroup groupbuttons1 = (viewgroup)findviewbyid(r.id.linearlayout1); view v1; final button backgrounda = (button) findviewbyid(r.id.a); final button backgroundb = (button) findviewbyid(r.id.b); final button backgroundc = (button) findviewbyid(r.id.c); final button backgroundd = (button) findviewbyid(r.id.d); final button backgrounde = (button) findviewbyid(r.id.e); final random random1 = new random(); final random random2 = new random(); for(int = 0; < groupbuttons1.getchildcount(); i++) { v1 = groupbuttons1.getchildat(i); if(v1 instanceof button) v1.setonclicklistener(new button.onclicklistener() { @suppresslint("cutpasteid") //legato ai button inferiori public void onclick(view view){ backgrounda.setonclicklistener(new view.onclicklistener(){ public void onclick(view view){ if(a < 2){ int randomint1 = random1.nextint(deck.length()); int drawableida = deck.getresourceid(randomint1, -1); backgrounda.setbackgroundresource(drawableida); ++; } } }); backgroundb.setonclicklistener(new view.onclicklistener(){ public void onclick(view view){ if (b < 2){ int randomint2 = random1.nextint(deck.length()); int drawableidb = deck.getresourceid(randomint2, -1); backgroundb.setbackgroundresource(drawableidb); b ++; } backgroundb.setenabled(false); } }); backgroundc.setonclicklistener(new view.onclicklistener(){ public void onclick(view view){ if (c < 2){ int randomint3 = random1.nextint(deck.length()); int drawableidc = deck.getresourceid(randomint3, -1); backgroundc.setbackgroundresource(drawableidc); c ++; } backgroundc.setenabled(false); } });

sorry indentation

your programme storing values of a,b,c alter ever made them have them incremented. after few clicks, a,b,c above 2 , never able go downwards below 2.

java android eclipse

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -