0

This question is based on my other question, make sure to take a look at it: Android - Generate non-repetitive random numbers

I have a collection that shuffles, but how can I pick the numbers one by one after "next" button is pressed?

ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i=1; i<11; i++) {
        list.add(new Integer(i));
    }
    Collections.shuffle(list);

This code is executed when the app is opened.

qid = 

This code is executed after "Next" button is pressed.

I'm confused on what the question id(qid) should be.

Thanks in advance!

Community
  • 1
  • 1

1 Answers1

0

Maintain a counter. Call your method.

static int counter = 0;

public static int getNextQuestion(ArrayList<Integer> list)
{
 if(counter == list.size() + 1) return -1;
 return list.get(counter++);
}
Uma Kanth
  • 5,659
  • 2
  • 20
  • 41