Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7914297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:04:19+00:00 2026-06-03T14:04:19+00:00

I made a fairly solid quiz game in Android for my class where 10

  • 0

I made a fairly solid quiz game in Android for my class where 10 random questions are picked from an array. The way it’s working right now is that the user enters the answer in an EditText field. I’m also happy that I was able to figure out how not to get duplicate questions using a simple shuffle algorithm so every question thrown at the user is unique (I’m actually pretty proud of that).

Ideally wanted to make the game to be multiple choice but I ran out of time and I submitted it as above. But I’ve been thinking about ways to make the game betters and user friendly and I think the EditText choice is not ideal IMO. So I’ve been thinking about rewriting it like this:

  1. A random question is selected;
  2. The question will display 4 random answer choices, and one of them will be the right answer;
  3. I will use RadioButtons and RadioGroup for the answer selection;
  4. The tricky part: I want the answer choices to be displayed and sorted randomly, for example:
    • questions x gets selected and answer choice will be displayed in a random order a, b, c, rightAnswer;
    • then question y gets selected and answer choices will be b, rightAnswer, c, a
    • etc…

So I was wondering if someone could point me in the right direction on how to achieve this. I’m not asking for full code, just places where I could read more about it and help me figure it out. All I seem to find in SO are ways to get random questions.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:04:20+00:00Added an answer on June 3, 2026 at 2:04 pm

    create an array to hold your answers. and then choose a random number from 0-[array.length] and set that index in the array to the correct answer. ie:

    int[] answers = new int[4];
    answers[0] = getRandomAnswer();
    answers[1] = getRandomAnswer();
    answers[2] = getRandomAnswer();
    answers[3] = getRandomAnswer();
    
    int correctIndex = Random.nextInt(0,4); // Maybe off by 1? I didn't compile
    answers[correctIndex] = correctAnswer;
    

    Now you have an array that contains 3 random answers and 1 correct answer. You’ll want to either make sure that getRandomAnswer() method won’t return the correct answer to you, or check your array at this point for multiple instances of the correct answer and if they exist remove all but one.

    you could populate a RadioGroup with the answers in your array and you know if the user is correct by checking against the correctIndex variable when they select one of the radio buttons in the group.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

fairly new to Android development. I made a function for the user to call
I'm building a fairly large enterprise application made in python that on its first
I have been playing around a bit with a fairly simple, home-made search engine,
I've made this fairly simple View. It's supposed to animate a red line that
I'm fairly new to ggplot. I have made a bumpplot using code posted below.
I'm fairly new to OOP in PHP, I've made a couple of basic scripts
I'm working on a fairly big (I think - is 32 projects big?) multi-project
We've got a fairly large amount of code that just made the jump to
I am fairly new to Silverlight. I have an application I'm working on that
I've made a fairly basic AJAX chat with PHP & MySQL. The chat messages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.