-1

I am developing an application which involves a quiz in it. I have used a viewflipper for displaying question, as i press the next button it flips to next question. However, I wish to display these questions randomly. I have parsed an xml and displayed the questions n its options !

HelpNeeded
  • 21
  • 1
  • 3

1 Answers1

1

Assuming that all your questions stored in array or some data structure e.g. ArrayList

You need to define a single random object only once in your activity

e.g.

Random random = new Random();

Get the next question index:

int nextQuestionIndex = random.nextInt(n); // where n is the total number of questions
iTech
  • 18,192
  • 4
  • 57
  • 80