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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:13:19+00:00 2026-06-18T01:13:19+00:00

Im new to android.. I have three ArrayList hashmap..one is for questions, second is

  • 0

Im new to android..

I have three ArrayList hashmap..one is for questions, second is for question id and third is for answers..

I got the questions and question id and answers in JSON object.. Now i want to display the question and answers…What i need is,
I have three ArrayList. QtnsArraylist1(ques1) contains 100 elements(100 questions) and QuestidArraylist contains 100 id’s and AnsArraylist2(answ1) contains 400 elements( 400 Answers, for each question 4 options totally 400 elements). I want to get these values from hashmap..

For my first Question in QtnsArraylist1(ques1) i have to get first 4 elements from AnsArraylist2(answ1) based upon the hashmap key questionid.Similarly if i give next button it display for question 2,3,4… .These all should do in onPostExecute() How i can get this?

Thanks in advance..

  protected void onPostExecute(String file_url) {
        pDialog.dismiss();       
        ques1=new ArrayList<String>(new HashSet<String>(ques1));
        System.out.println(" Question array:"+ques1);
        String[] quesArr = new String [ques1.size()];
        quesArr = ques1.toArray(quesArr);
        for(String s: quesArr){
            System.out.println("All Array Questions:"+s);
            final TextView txtque = (TextView) findViewById(R.id.que_txt);
            final String text=ques1.get(j).toString();
            System.out.println("Array:"+text);
            txtque.setText(text);
        }            
        answ1=new ArrayList<String>(new ArrayList<String>(answ1));
        System.out.println(" Answer array:"+answ1);
        String[] answArr = new String [answ1.size()];
        answArr = answ1.toArray(answArr);
        for(String A: answArr){
            // final Object getName0 = answArr[0].toString();
            // final Object getName1 = answArr[1].toString();
            // final Object getName2 = answArr[2].toString();
            // final Object getName3 = answArr[3].toString();
            Collections.sort(answ1, new Comparator<String>() {
                @Override
                public int compare(String s1, String s2) {
                    return s1.compareToIgnoreCase(s2);
                }
            });
        System.out.println("All Array Answers:"+A);    
        }                 
        btn_practicerg =(RadioGroup) findViewById(R.id.rdgroup);
        btn_practice1 = (RadioButton) findViewById(R.id.RB1);
        btn_practice1.setText(String.valueOf(answArr[0]));
        btn_practice2 = (RadioButton) findViewById(R.id.RB2);
        btn_practice2.setText(String.valueOf(answArr[1]));
        btn_practice3 = (RadioButton) findViewById(R.id.RB3);
        btn_practice3.setText(String.valueOf(answArr[2]));
        btn_practice4 = (RadioButton) findViewById(R.id.RB4);
        btn_practice4.setText(String.valueOf(answArr[3]));              
        Button nextBtn = (Button) findViewById(R.id.nxt_btn);
        nextBtn.setOnClickListener(new Button.OnClickListener(){
            public void onClick(View v){
            j++;
            TextView txtque = (TextView) findViewById(R.id.que_txt);
            txtque.setText(ques1.get(j).toString());                               
            k++;
            btn_practice1.setText(answ1.get(k).toString());
            k++;
            btn_practice2.setText(answ1.get(k).toString());
            k++;
            btn_practice3.setText(answ1.get(k).toString());
            k++;
            btn_practice4.setText(answ1.get(k).toString());
  • 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-18T01:13:19+00:00Added an answer on June 18, 2026 at 1:13 am

    You can put your answer as HashMap in an Arraylist. That would make all your ArrayList of same size.

    For instance,

    HashMap<String, String> hm = new HashMap<String, String>();
    hm.put("1", "abc");
    hm.put("2", "def");
    hm.put("3", "ghi");
    hm.put("4", "jkl");
    
    ArrayList<HashMap<String, String>> lstAns = new ArrayList<HashMap<String,String>>();
    lstAns.add(hm);
    

    To access answers:

    System.out.println("answer1 " + lstAns.get(index).get("1")); // gives "abc"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm making an android quiz app. there are have one question an four answers,
I'm new to android apps development and I have a basic sqlite question. What
i'm new at Android world, and i have a doubt, is there any method
hi to all i am new to android i have to send my different
I am a bit new with android but I have some java experience. So
i am creating a new android application.i am using the table layout. I have
Ok, im fairly new to android but i have managed to teach myself the
I am new in Android. I have develop an app. And now want to
I am new to Android. I have tried an sample application for status bar
Hi I am new to android and I am having an issue I have

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.