As below json response, i want to show poolquestions with answers related to that poolquestion in recyclerview. already i have defined a adapter for recyclerview and model class for poolquestions and answers to save json values. but my question is while i am going to extract data from model class in adapter all poolanswers are showing in all parent poolquestions.
Here is my json:
{
  "data": [
    {
      "pooltitle": "Who is the best Actor in India",
      "pooldetails": [
        {
          "poolquestions": "Who is the best actor in Bollywood?",
          "poolanswer": [
            {
              "answer": "Amir Khan",
              "percent": 38
            },
            {
              "answer": "Amitabh Bachhan",
              "percent": 25
            },
            {
              "answer": "Salman Khan",
              "percent": 0
            },
            {
              "answer": "Akshay Kumar",
              "percent": 38
            }
          ]
        },
        {
          "poolquestions": "Who has most female fan following?",
          "poolanswer": [
            {
              "answer": "Amitabh Bachhan",
              "percent": 13
            },
            {
              "answer": "Amir Khan",
              "percent": 38
            },
            {
              "answer": "Salman Khan",
              "percent": 13
            },
            {
              "answer": "Akshay Kumar",
              "percent": 38
            }
          ]
        },
        {
          "poolquestions": "Who is most popular actor in social media?",
          "poolanswer": [
            {
              "answer": "Amir Khan",
              "percent": 27
            },
            {
              "answer": "Amitabh Bachhan",
              "percent": 36
            },
            {
              "answer": "Salman Khan",
              "percent": 18
            },
            {
              "answer": "Akshay Kumar",
              "percent": 18
            }
          ]
        }
      ]
    }
  ],
  "status": 1
}
Main Activity AsyncTask code:
private List<PollsData> pollDataArrayList;
private List<PollQstWithOptions> pollQSTOptionsList = new ArrayList<>();
if ("1".equalsIgnoreCase(status)) {
            try {
                JSONArray data = js.getJSONArray("data");
                for (int i = 0; i < data.length(); i++) {
                    JSONObject detailsData = data.getJSONObject(i);
                    JSONArray pollQstArray = detailsData.getJSONArray("pooldetails");
                    for (int j = 0; j < pollQstArray.length(); j++) {
                        JSONObject poll = pollQstArray.getJSONObject(j);
                        String poolquestion_ = poll.getString("poolquestions");
                        pollDataArrayList = new ArrayList<>();
                        JSONArray poolanswerArray = poll.getJSONArray("poolanswer");
                        for (int k = 0; k < poolanswerArray.length(); k++) {
                            JSONObject pollOptions = poolanswerArray.getJSONObject(k);
                            String options = pollOptions.getString("answer");
                            int percent = pollOptions.getInt("percent");
                            PollsData pollDetails = new PollsData(options, percent);
                            pollDataArrayList.add(pollDetails);
                        }
                        PollQstWithOptions mPollQstWithOptions = new PollQstWithOptions(poolquestion_, pollDataArrayList);
                        pollQSTOptionsList.add(mPollQstWithOptions);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            mAdapter = new PollAdapter2(ActivityPollDetails.this, pollQSTOptionsList);
            RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(ActivityPollDetails.this);
            recyclerView.setLayoutManager(mLayoutManager);
            recyclerView.setHasFixedSize(true);
            recyclerView.setAdapter(mAdapter);
        }
Adapter class:
public class PollAdapter2 extends RecyclerView.Adapter<PollAdapter2.MyViewHolder> {
    private List<PollQstWithOptions> dataList;
    Context context;
    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView txt_poll_question;
        ProgressBar progress1;
        LinearLayout mainLayout;
        public MyViewHolder(View view) {
            super(view);
            txt_poll_question=(TextView)view.findViewById(R.id.txt_poll_question);
            mainLayout=(LinearLayout)view.findViewById(R.id.mainLayout);
        }
    }
    public PollAdapter2(Context mContext, List<PollQstWithOptions> dataList) {
        this.dataList = dataList;
        this.context=mContext;
    }
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.card_poll_qst_with_ans, parent, false);
        MyViewHolder viewHolder = new MyViewHolder(v);
        return viewHolder;
    }
    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        final PollQstWithOptions poll = dataList.get(position);
        holder.txt_poll_question.setText(poll.getPollQstName());
        for(int i=0; i<dataList.size();i++){
            PollQstWithOptions itemsData = dataList.get(i);
            for(int j=0;j<itemsData.getOptionList().size();j++){
                System.out.print("child pos:: "+j);
                PollsData mPollsData = itemsData.getOptionList().get(j);
                TextView text = new TextView(context);
                text.setLayoutParams(new TableRow.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
                text.setText(mPollsData.getAns1());
                holder.mainLayout.addView(text);
            }
        }
    }
    @Override
    public int getItemCount() {
        return dataList.size();
    }
}