title: How to have a ListView/RecyclerView inside a parent RecyclerView?
body: <p>I want to add some child Views (List Items), which come to me from JSON formatted data. Each child list is under a parent list item row. How can I populate it in <code>RecyclerView</code> for each row item (Parent items with child list items)?</p>
  
  <p>I have tried using <code>RecyclerView</code> within <code>RecyclerView</code> parent row (for populating child lists), but here child views are not visible.</p>
  
  <h1>Parent Adapter Class</h1>
  
  <pre><code>public class DigitizedPrescAdapter extends RecyclerView.Adapter&lt;DigitizedPrescAdapter.ListItemViewHolder&gt;{
      private List&lt;PrescriptionModal&gt; prescriptionList;
  
      MedicinesInPrescAdapter adapter;
  
      public DigitizedPrescAdapter(List&lt;PrescriptionModal&gt; prescriptionListModal) {
  
          if (prescriptionListModal == null) {
              throw new IllegalArgumentException(
                      "PrescriptionList must not be null");
          }
          this.prescriptionList = prescriptionListModal;
      }
  
      @Override
      public ListItemViewHolder onCreateViewHolder(
              ViewGroup viewGroup, int viewType) {
          View itemView = LayoutInflater.
                  from(viewGroup.getContext()).
                  inflate(R.layout.item_row_digitised_request,
                          viewGroup,
                          false);
          return new ListItemViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(
              ListItemViewHolder viewHolder, int position) {
          PrescriptionModal model = prescriptionList.get(position);
  
          viewHolder.prescnum.setText("Prescription "+ ++position);
          viewHolder.prescNo.setText("Prescription: "+model.getPrescriptionID());
          viewHolder.doctorType.setText("Type: "+model.getDoctorType());
          viewHolder.doctorName.setText("Doctor: "+model.getDoctorName());
          viewHolder.patientName.setText("Patient: "+model.getPatientName());
  
          adapter = new MedicinesInPrescAdapter(model.getLstproduct());
          viewHolder.lstMedicines.setAdapter(adapter);
  
      }
  
      @Override
      public int getItemCount() {
          return prescriptionList.size();
      }
  
      public final static class ListItemViewHolder
              extends RecyclerView.ViewHolder {
  
          TextView prescnum;
          TextView prescNo;
          TextView doctorType;
          TextView patientName;
          TextView doctorName;
          CheckBox selectAll;
          RecyclerView lstMedicines;
  
          public ListItemViewHolder(View itemView) {
              super(itemView);
              prescnum = (TextView) itemView.findViewById(R.id.prescnum);
              prescNo = (TextView) itemView.findViewById(R.id.prescNo);
              doctorType = (TextView) itemView.findViewById(R.id.doctorType);
              patientName = (TextView) itemView.findViewById(R.id.patientName);
              doctorName = (TextView) itemView.findViewById(R.id.doctorName);
              selectAll = (CheckBox) itemView.findViewById(R.id.selectAll);
              lstMedicines = (RecyclerView) itemView.findViewById(R.id.lstAllMedicines);
              MyLinearLayoutManager layoutManager = new MyLinearLayoutManager(itemView.getContext(),LinearLayoutManager.VERTICAL,false);
              lstMedicines.setHasFixedSize(false);
              lstMedicines.setLayoutManager(layoutManager);
          }
      }
  }
  </code></pre>
  
  <h1>Child Adapter Class</h1>
  
  <pre><code>public class MedicinesInPrescAdapter extends RecyclerView.Adapter&lt;MedicinesInPrescAdapter.MedicineListItemViewHolder&gt;{
  
      List&lt;Modal_Product_List&gt; prescriptionProducts;
  
      public MedicinesInPrescAdapter(List&lt;Modal_Product_List&gt; prescriptionListProd) {
  
          if (prescriptionListProd == null) {
              throw new IllegalArgumentException(
                      "PrescriptionProductList must not be null");
          }
          this.prescriptionProducts = prescriptionListProd;
      }
  
      @Override
      public MedicineListItemViewHolder onCreateViewHolder(
              ViewGroup viewGroup, int viewType) {
          View itemView = LayoutInflater.
                  from(viewGroup.getContext()).
                  inflate(R.layout.item_row_medicine_productlist,
                          viewGroup,
                          false);
          return new MedicineListItemViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(
              MedicineListItemViewHolder viewHolder, int position) {
          Modal_Product_List modelMedicine = prescriptionProducts.get(position);
  
          viewHolder.medicineName.setText(modelMedicine.getMedicinename());
          viewHolder.medQty.setText(modelMedicine.getQuantity());
          viewHolder.days.setText("30");
          viewHolder.Amount.setText(modelMedicine.getQuantitybasedprice());
      }
  
      @Override
      public int getItemCount() {
          return prescriptionProducts.size();
      }
  
      public final static class MedicineListItemViewHolder
              extends RecyclerView.ViewHolder {
  
          TextView medicineName;
          EditText medQty;
          TextView days;
          TextView Amount;
          CheckBox selectMe;
  
          public MedicineListItemViewHolder(View itemView) {
              super(itemView);
              medicineName = (TextView) itemView.findViewById(R.id.medicineName);
              medQty = (EditText) itemView.findViewById(R.id.medQty);
              days = (TextView) itemView.findViewById(R.id.days);
              Amount = (TextView) itemView.findViewById(R.id.amount);
              selectMe = (CheckBox) itemView.findViewById(R.id.selectMe);
          }
      }
  }
  </code></pre>