I am trying to randomize quiz questions from firebase. I am trying to generate random numbers from 0-50 add them in a array and once the number is used I want that number to be removed. But it goes forever with repeatation, here is piece of code that I use to generate random
public void updateQuestion (){
for (int i = 0; i < 50; i++) {
questionNos.add(i);
}
Random r = new Random();
index = r.nextInt(questionNos.size()-1);
mQuestionNo = questionNos.remove(index);
and to switch activity
if (questionNos == null ){
Intent i = new Intent(qiozphy.this,Score.class);
i.putExtra("Score",mScore);
startActivity(i);
}
I am calling updatequestion() on oncreate and 4 choice butons of the quiz.
Aucun commentaire:
Enregistrer un commentaire