dimanche 21 août 2016

How to not duplicate arrays in random function on Java

Well, i made this code to do a array function. Now i want to not repeat any array until all arrays have appeared.

Here's my code:

Resources res = getResources();

    myString = res.getStringArray(R.array.myArray);



    Button chain1Button = (Button) findViewById(R.id.next_button);

    chain1Button.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View v) {
            String q = myString[rgenerator.nextInt(myString.length - 1)];

            TextView tv = (TextView) findViewById(R.id.text1);
            tv.setText(q);
        }
    });




Aucun commentaire:

Enregistrer un commentaire