title: How to use Recyclerview in Recyclerview Adapter
body: <p>How to setup recyclerview in recyclerview adapter<br></p>
  
  <p><strong>Fragment_A</strong><br>
  Setup recyclerview Adapter_A in Fragment_A</p>
  
  <pre><code> @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
  
  
      View view = inflater.inflate(R.layout.fragment_a, container, false);
      List&lt;Model_A&gt; model = new ArrayList&lt;Model_A&gt;();
  
      Adapter_A adapter  = new Adapter_A(model,getActivity().getApplicationContext());
      LinearLayoutManager llm = new LinearLayoutManager(getActivity().getApplication());
  
      RecyclerView r = (RecyclerView) view.findViewById(R.id.fragment_a_recyclerview);
      r.setHasFixedSize(true);
      r.setLayoutManager(llm);
      r.setAdapter(adapter);
  
      model.add(new Model_A("A"));
      model.add(new Model_A("B"));
      model.add(new Model_A("C"));
      model.add(new Model_A("D"));
      model.add(new Model_A("E"));
      model.add(new Model_A("F"));
      model.add(new Model_A("G"));
      model.add(new Model_A("E"));
      model.add(new Model_A("F"));
      model.add(new Model_A("G"));
  
      return view;
  
  }
  </code></pre>
  
  <p><p><br><br><br><br>
  <strong>Adapter_A</strong><br>
  Setup recyclerview Adapter_A_Card in Adapter_A</p>
  
  <pre><code>public class Adapter_A extends RecyclerView.Adapter&lt;Adapter_A.ModelViewHolder&gt;{
      List&lt;Model_A&gt; model;
      Context context;
  
  
      public Adapter_A(List&lt;Model_A&gt; model,Context context){
          this.model = model;
          this.context = context;
      }
      @Override
      public ModelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_a, parent, false);
          return new ModelViewHolder(itemView);
      }
  
  
      @Override
      public void onBindViewHolder(ModelViewHolder holder, int position) {
          Model_A m = model.get(position);
          TextView header = (TextView) holder.itemview.findViewById(R.id.cardview_a_header);
          header.setText(m.header);
  
  
  
          new Load(holder.itemView,context,position).Calls();
      }
  
      @Override
      public int getItemCount() {
          return model.size();
      }
  
      class ModelViewHolder extends RecyclerView.ViewHolder{
          protected View itemview;
          public ModelViewHolder(View itemView) {
              super(itemView);
              this.itemview = itemView;
          }
      }
  
  
      class Load{
          View view;
          Context context;
          int id;
  
          public Load(View view,Context context,int id){
              this.view = view;
              this.context =context;
              this.id = id;
          }
          public void Calls(){
              id=id+1;
              String url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=__HIDDENKEY_&amp;q=love&amp;page_limit=50&amp;page=" + id;
  
  
              JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(url,
                      new Response.Listener&lt;JSONObject&gt;() {
                          @Override
                          public void onResponse(JSONObject response) {
                              List&lt;Model_A_Card&gt; model_a_card = new ArrayList&lt;Model_A_Card&gt;();
                              Adapter_A_Card adapter = new Adapter_A_Card(model_a_card,context);
                              LinearLayoutManager llm = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false);
  
                              RecyclerView r = (RecyclerView) view.findViewById(R.id.cardview_a_recyclerview);
                              r.setHasFixedSize(true);
                              r.setLayoutManager(llm);
  
                              r.setAdapter(adapter);
  
                              try {
                                  JSONArray movies = response.getJSONArray("movies");
  
                                  for (int i = 0; i &lt; movies.length(); i++) {
  
                                      JSONObject obj = movies.getJSONObject(i);
  
                                      Model_A_Card m = new Model_A_Card();
  
                                      m.title = obj.getString("title");
  
                                      JSONObject objImage = obj.getJSONObject("posters");
                                      m.image = objImage.getString("original");
                                      model_a_card.add(m);
                                  }
                              }catch (JSONException e){
  
                              }
  
                              adapter.notifyDataSetChanged();
                          }
                      }, new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
  
                  }
              });
  
  
              NetworkVolley.getInstance(context).addToRequestQueue(jsonObjectRequest);
          }
      }
  
  }
  </code></pre>
  
  <p><b>nothing error using this code</b><br>
  when i scroll recyclerview with Adapter_A,
  always refresh recyclerview with Adapter_A_Card <br></p>
  
  <p>i try setup inside <b>onCreateViewHolder</b> , it success, not refresh, <br>
  But Position is not there <br>
  Please help me</p>
  
  <pre><code>    public class Adapter_A extends RecyclerView.Adapter&lt;Adapter_A.ModelViewHolder&gt;{
  
      @Override
      public ModelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_a, parent, false);
          int position = 0; // NOT POSITION
          new Load(itemView,context,position).Calls();
          return new ModelViewHolder(itemView);
      }
  
  }
  </code></pre>