Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the hashmap values?
    text
    copied!<p>Im new to android..</p> <p>I have three ArrayList hashmap..one is for questions, second is for question id and third is for answers..</p> <p>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..</p> <p>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?</p> <p>Thanks in advance..</p> <blockquote> <pre><code> protected void onPostExecute(String file_url) { pDialog.dismiss(); ques1=new ArrayList&lt;String&gt;(new HashSet&lt;String&gt;(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&lt;String&gt;(new ArrayList&lt;String&gt;(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&lt;String&gt;() { @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()); </code></pre> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload