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 7745295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:58:42+00:00 2026-06-01T09:58:42+00:00

I am developing a quiz based app. The quiz contains 1 question and 4

  • 0

I am developing a quiz based app. The quiz contains 1 question and 4 multiple choice answers.

When the user selects any one of the option out of 4, if its a right answer then something like “Your answers is right” should be displayed, else “Your answer is wrong” should be displayed along with the correct answer.

And also there are 2 buttons (next and back), one to go for next question, the other to go back.

Can someone tell me how to write the code for going back to previous question?

I have done something like this:

 private void getShuffledArray() 
    {
        // TODO Auto-generated method stub
        for (int i = 1; i <= SIZE; i++) 
        {
            quizIndexList.add(i);

        }
        Collections.shuffle(quizIndexList);
        Log.d("ERR", "List A shuffling" + quizIndexList);

    }

    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.button1:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) {
                displayAnswer();


            }

            break;
        case R.id.button2:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) {
                displayAnswer();
            }
            break;

        case R.id.button3:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) {
                displayAnswer();
            }
            break;

        case R.id.button4:
            Log.d("ERR", v.getTag().toString());
            if (v.getTag().toString().equalsIgnoreCase("right")) {
                displayAnswer();
            }
            break;

        case R.id.btn_next:
//          lyt_ans.setVisibility(View.GONE);
//          lyt_quest.setVisibility(View.VISIBLE);
            counter += 1;
            if (counter >= SIZE) {
                Collections.shuffle(quizIndexList);
                counter = 0;
            }
            getInfoFromDB(quizIndexList.get(counter));
            reLoad();
            break;

        case R.id.btn_bck:
             btn_next.setOnClickListener(new OnClickListener() 
               {

                public void onClick(View v) 
                {
                    // TODO Auto-generated method stub

                    finish();
                }
               });

        }

}

Any help is appreciable and thank you 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-01T09:58:43+00:00Added an answer on June 1, 2026 at 9:58 am

    @Rithesh — Not getting your code but simple logic for this as follows
    What you need
    1) Question array
    2) Answers Arraylist (Or say two dimensional array) something like ArrayList<ArrayList<String>>
    3) Answer index for each question (It should match to question index
    4) A view with a textview (To show question), RadioGroup which consist 4 Radio Buttons so that it will only select one at a time
    5) Two buttons next & previous
    6) Main thing Add setOnCheckedChangeListener to your radio group it will get fire only when user select any answer then check which radio button is checked (For this set tag of radio button to it’s position) so suppose question no is 2 & radio checked position is 3 then just check in your answer array for answer no & if it matches you can show toast & if it’s not match then find write answer from Answers arraylist & show it in toast or by alert.
    7) now when you click on next button change text view’s text to next question & radio button’s text to next set of answer & vice versa for previous button click

    This is logical cant provide you code

    Code to set options

    RadioButton option_rdb1 = (RadioButton) findViewById(R.id.option_rdb1);
    setOptions(0);
    
    // if you used ArrayList<ArrayList<String>> optionslist
    public void setOptions(int index){
    if((index-1) <= optionsList.size()){
        ArrayList<String> temp = optionslist.get(index);
        options_rdb1.setText(temp.get(0).toString();
        options_rdb1.setText(temp.get(0).toString();
        options_rdb1.setText(temp.get(0).toString();
        options_rdb1.setText(temp.get(0).toString();
      }
    }
    

    just call setOptions in next previous with index of question.
    I used index-1 as arraylist start with 0 So it depends on you how you use index.
    This way you can set first options Also in you function which you will call on next button click use above line of code to set next

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

Sidebar

Related Questions

I am developing an quiz based app in that when the user clicks any
I am developing an quiz based app and i wanted to know how i
I am developing an quiz based application. I wanted to know like, how can
I'm developing an Android app which is a quiz. On the other hand, I'm
I am developing Quiz project. In DetailsView I want to display the Question and
ok i am developing a quiz ... the question's options ... so i am
I am developing a quiz ui where multiple views will be shown to the
I'm developing an app, which be be a game/quiz type application for testing a
I am developing a quiz application which consists of a question and three options
Developing a WP7 app, and I'm trying to post something to the user's feed.

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.