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

The Archive Base Latest Questions

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

I am working on quiz application. It contains 2 types of tests. The first

  • 0

I am working on quiz application. It contains 2 types of tests. The first test contains questions with 3 options fixed. *The second test contains questions with options not fixed. i.e the options may be 4 or 5 or 6 based on the question.*
After the test I need to display the review page. Here is the review page code for the first type of test with fixed options.(Review page should contain the questions displayed for the test at that time)

My Code:

Review.java

public class Review extends Activity {

    static ArrayList selectedoptionids = Test1.listarray;
    static ArrayList<ArrayList<String>> questionslist = Test2.stringList1;
    static ArrayList<ArrayList<String>> alloptionlist = Test2.optionstablelist;
    static ArrayList<ArrayList<String>> all = new ArrayList<ArrayList<String>>();

    ListView list;
    Button next;
    String op1, op2, op3, op4, op5;
    ArrayList<String> arr1;
    ArrayList<String> arr2;

    int a, i;
    static int k = 0;
    static int p = 1;

    static List<mainlist> entirelist = new ArrayList<mainlist>();
    String  quest;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.review);

        list = (ListView) findViewById(R.id.listlist);

        View header = getLayoutInflater().inflate(
                R.layout.listview_header_text, null);
        list.addHeaderView(header, null, false);

        View footerView = getLayoutInflater().inflate(
                R.layout.listview_footer_text, null);
        list.addFooterView(footerView, null, false);

        next = (Button) findViewById(R.id.next);

        eachquestion();

        lvAdapter adapter = new lvAdapter(this, entirelist) {
            public boolean areAllItemsEnabled() {
                return false;
            }

            public boolean isEnabled(int position) {
                return false;
            }
        };
        list.setAdapter(adapter);
    }


    public void eachquestion() {
        arr1 = new ArrayList<String>();

        for (i = p - 1; i < p + 3; i++) {

            arr1 = questionslist.get(i);
            arr2 = new ArrayList<String>();

            for (int j = 0; j < 5; j++) {

                arr2 = alloptionlist.get(0);
                    if (j == 0) 
                        op1 = arr2.get(2);

                     else if (j == 1) 
                        op2 = arr2.get(2);

                     else if (j == 2) 
                        op3 = arr2.get(2);
                }

            }

    entirelist.add(new mainlist(quest, op1, op2, op3));

        }
    }

}

mainlist.java

public class mainlist {
    String question,option1,option2,option3;

    public mainlist(String question,String option1,String option2,String option3) {
        super();
        this.question = question;
        this.option1 = option1;
        this.option2= option2;
        this.option3 = option3;
        }

    public String getquestion() {
        return question;
    }
    public void setquestion(String question) {
        this.question = question;
    }

    public String getoption1() {
        return option1;
    }
    public void setoption1(String option1) {
        this.option1 = option1;
    }

    public String getoption2() {
        return option2;
    }
    public void setoption2(String option2) {
        this.option2 = option2;
    }

    public String getoption3() {
        return option3;
    }
    public void setoption3(String option3) {
        this.option3 = option3;
    }
}

lvAdapter.java

public class lvAdapter extends BaseAdapter implements OnClickListener {
    private Context context;
     List<mainlist> list11 = Review.entirelist;

    public lvAdapter(Context context, List<mainlist> list11 ) {
        this.context = context;
        this.list11 = list11 ;
    }
    public int getCount() {
        return list11.size();
    }
    public Object getItem(int position) {
        return list11.get(position);
    }

    public long getItemId(int position) {
        return position;
    }


    public View getView(int position, View convertView, ViewGroup viewGroup) {

        mainlist inst  = list11.get(position); 

        if (convertView == null) 
        {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.reviewrow, null);
        }

        TextView question = (TextView) convertView.findViewById(R.id.textView2);
        tvPhone.setText(inst.getquestion());

        TextView option1 = (TextView) convertView.findViewById(R.id.op1);
        option1.setText(inst.getoption1());

        TextView option2 = (TextView) convertView.findViewById(R.id.op2);
        option2.setText(inst.getoption2());

        TextView option3 = (TextView) convertView.findViewById(R.id.op3);
        option3.setText(inst.getoption3());

        return convertView;
    }

    @Override
    public void onClick(View v) {

    }
}

Now my problem is for the first test as we know the number of options are 3 so I have written the setter and getter methods for 1 question and 3 options and it is working fine. But for the second type of test how can I write the mainlist.java class for generating the setter and getter methods for unknown number of options.

Please help me regarding this…I am struggling for this since 3 days….

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:28:50+00:00Added an answer on May 30, 2026 at 3:28 pm

    Ok what you will need is to make a class named Quiz something like this:

    public class Quiz
    {
        private String question;
        private ArrayList<String> options;   // no need to get separate variable for every option
        public Quiz(String q, ArrayList<String> o)
        {
           super();  this.question = q; this.options = o;
        }
        //setter and getter.. like setOptions() getOptions() setQuestion() etc.. :/
    }
    

    now in make your entirelist a Quiz List like this:

    List<Quiz> entirelist = new ArrayList<Quiz>();
    

    and now pass single quiz + options to entirelist like this:

    ArrayList<String> options = new ArrayList<String>();
    options.add(op1);
    options.add(op2);
    options.add(op3);
    entirelist.add(new Quiz(quest,options));
    

    now in adapter’s getView(), remove all options’ TextViews and add them dnamically something like this:

    public View getView(int position, View convertView, ViewGroup viewGroup) {
            if (convertView == null) 
            {
                LayoutInflater inflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = inflater.inflate(R.layout.reviewrow, null);
            }
            Quiz currentQuiz = list11.get(position);
            TextView question = (TextView) convertView.findViewById(R.id.textView2);
            tvPhone.setText(currentQuiz.getquestion());
    
            // now add options dynamically..
            ArrayList<String> options = currentQuiz.getOptions();
            for(String option : options)
            {
                TextView optionTextView = new TextView(context);
                optionTextView.setText(option);
                convertView.add(optionTextView);
            }
            return convertView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a java quiz application. The application will consist of 20 questions
I am working on quiz application . For each question there are multiple options
I am working on quiz application . For each question there are multiple answers
I am Working on the quiz application . Here I am using Viewpager indicator
I am working on a quiz application. In that I am displaying the question
I am working on creating a PHP/mysql quiz application. I outlined my table structure
I'm currently working on a project where I'm essentially creating a quiz application. It
I am working on php quiz-test script. I need to know which selected and
I'm currently working on a quiz program using PHP/mySQL (my first time ever actually
I am working on a code for a quiz test, here function run($id){ //Is

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.