简体   繁体   中英

what is wrong with this loop? - android studio

I wrote this codes for make a loop and save all name to an array but loop is ending at first click it make the button false, it have to make the button false after 10 names but it is not working how can I edit this code?

int oyuncuSayisi = 0;
                for (int a = 0; a < 10; a++) {
                    isimGirisString = oyuncular[a];
                    oyuncuSayisi++;
                }
                if (oyuncuSayisi > 9) {
                    oyuncuKayit.setEnabled(false);

you dont need a loop is it only a condition. Try something like this:

int counter=0; //init your variable somewhere

/*...


*/
@Override
public void OnClick(View v){
    conter++;
    isimGirisString = oyuncular[a];
    if(conter==10){
    //do your action here
    oyuncuKayit.setEnabled(false);
    }
}

Then it will run alwais you click the button until 9 times

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM