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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:02:56+00:00 2026-05-30T15:02:56+00:00

I am working on quiz application . For each question there are multiple answers

  • 0

I am working on quiz application. For each question there are multiple answers and so for that I have used checkboxes. In each page I am displaying single question with options and when next button is clicked next question will be displayed. So when multiple answers are selected by the user I need to store them in an arraylist and need to compare the selected answers with that in database. In my code I am storing the selected value id’s one by one but at a time it is storing only one value. How to store all the selected checkbox id’s in my arraylist?

My Code:

ArrayList<String> selchkboxlist;
CheckBox[] cbs;
 cbs = new CheckBox[20];
for(k=0; k<List3.size(); k++)
 { 
     arr = List3.get(k);
     cbs[k] = new CheckBox(getContext());
     Rl.addView(cbs[k]);
         cbs[k].setText((CharSequence) arr.get(2));
         cbs[k].setTextColor(Color.parseColor("#000000"));  
         cbs[k].setId(k);
         cbs[k].setOnClickListener( new View.OnClickListener()
         { 
             public void onClick(View v) 
             { 
                CheckBox cb = (CheckBox) v ; 
            if (((CheckBox) v).isChecked()) {
                chk = Integer.toString(v.getId());
                    selchkboxlist = new ArrayList<String>();
                    selchkboxlist.add(chk);
                    Toast.makeText(Select1.this, "Selected CheckBox ID" + v.getId(), Toast.LENGTH_SHORT).show();
            } else {
                 selchkboxlist.remove(chk);
              Toast.makeText(Select1.this, "Not selected", Toast.LENGTH_SHORT).show();
                }
         }
     });
 } 

Please help me regarding this….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-05-30T15:02:59+00:00Added an answer on May 30, 2026 at 3:02 pm

    Initialize the selchkboxlist before for loop….

    ArrayList<String> selchkboxlist=new ArrayList<String>();
    CheckBox[] cbs;
    cbs = new CheckBox[20];
    for(k=0; k<List3.size(); k++)
    { 
     arr = List3.get(k);
     cbs[k] = new CheckBox(getContext());
     Rl.addView(cbs[k]);
         cbs[k].setText((CharSequence) arr.get(2));
         cbs[k].setTextColor(Color.parseColor("#000000"));  
         cbs[k].setId(k);
         cbs[k].setOnClickListener( new View.OnClickListener()
         { 
             public void onClick(View v) 
             { 
                CheckBox cb = (CheckBox) v ; 
            if (((CheckBox) v).isChecked()) {
                chk = Integer.toString(v.getId());
                    selchkboxlist.add(chk);
                    Toast.makeText(Select1.this, "Selected CheckBox ID" + v.getId(), Toast.LENGTH_SHORT).show();
            } else {
                 selchkboxlist.remove(chk);
              Toast.makeText(Select1.this, "Not selected", Toast.LENGTH_SHORT).show();
                }
         }
     });
    

    }

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

Sidebar

Related Questions

I have a basic quiz/survey type application I'm working on, and I'd like to
I have little quiz game I've working on and am tracking correct answers. I
For a multiple choice quiz application i would like to show the dummy answers
The code is working!! I now have a quiz that does the following: A
I'm trying to grade a quiz application I would like to make. I have
I am working on a page that uses XPATH to traverse an XML document
I'm working to a system called Quiz ... The last thing that remains are
I have created an android quiz application where i have a feature Exam .
I'm working on very big project - quiz system (examination). And have a few
There is a jQuery quiz posted on the W3Schools site here... http://www.w3schools.com/quiztest/quiztest.asp?qtest=jQuery Question #16

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.