vendredi 13 mai 2016

android studio, sort int array for memory game

i have a question and i hope that someone of you can help me.

I am trying to make my own Memory Game App in Android Studio.

I created an ImageButton Array (bArray) in which all buttons are stored. In the oncreate method, i got a for loop to give every ImageButton a random Tag.

With the help of these Tags i assign one image to every ImageButton, but i only want one Image to be assigned twice and not e.g. three times.

So i need to find that Tags, that are assigned more than twice and to replace them with other Tags.

I dont know how to do that. I hope that you can help me. If you need more Information please just let me know.

   for(ImageButton b : bArray) {
       Random random = new Random();
       i_rndTag = random.nextInt(bilderArray.length);
       b.setTag(i_rndTag);
   }




Aucun commentaire:

Enregistrer un commentaire