I have 4 string arrays,each of these array’s length is 4. I also have four textviews . Now I want to randomly settext of that array’s indexes in the textviews. I have done this:
ansone.setText(Answera[0]);
anstwo.setText(Answerb[0]);
ansthree.setText(Answerc[0]);
ansfour.setText(Answerd[0]);
but its keeps the same sequence every time I run the application, I want to randomly select the arrays in different textviews like some time ‘ansone’ textview will set the text of Answerb[0], or ‘anstwo’ textview will set the text of Answerd[0] and so on. Thus everytime I run the application the textviews will randomly select the arrays from where it will be set text. How can I make it random?
Create an ArrayList array:
And then shuffle it:
Next, just put the result to each textviews: