1

I am making a Android quiz application. There is a start screen where the user will press start to see and answer questions. Each question will be its own activity where the question will be written as a text view and there will be 4 buttons for multiple choice. I will have more than 10 activities for questions and when the player presses start on the start screen, each question activity will be selected randomly when I initialize an array list with activity names and I will remove them from that list so the question will not be selected multiple times. How would after the player presses start, pick a random activity, answer the question to select another question activity. I was first thinking that I would return to the start menu activity and have the array list iterate it through a for loop. How would I control which activity to go to, maybe pass the Array list in a bundle through each activity?

  • check this http://stackoverflow.com/a/16000210/1320616 – Ankit Aggarwal Jan 05 '16 at 05:59
  • are you getting your questions from the web service or your are putting them in your string.xml – Chaudhary Amar Jan 05 '16 at 06:05
  • Generate a random number in range of 0 to (size of list-1), get the value(Activity name) at the random index form the list and remove that after showing the activity. Repeat this till you are left with only 1 entry in the list. – Akhil Jan 05 '16 at 06:18
  • The questions are being hard coded as different activities. – Calvin Kwan Jan 05 '16 at 06:32
  • Spynet, yes I was going to do that to reach each activity but after the user answers that activity, how would I return to the previous function where that functions runs to select a question activity to go to without user input. – Calvin Kwan Jan 05 '16 at 06:35

1 Answers1

0

Dont do that Use single Activity which will display random questions from database or arraylist.If you dont want reapet question.then remove that from arraylist.If you are using database then dont remove from db just add all selected que_id in list and get que from db which is not in this list

Jotiram Chavan
  • 375
  • 1
  • 8