what is wrong with this loop? - android studio

Akinci :

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);
thiago :

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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=393612&siteId=1