title: Recyclerview android with volley JsonArrayRequest with post parameters
body: <p>I want to load my recyclerview with JSON array. I am using volley for this .</p>
  
  <p>I am using <code>StringRequest</code> as of now.</p>
  
  <p>I want to post id and in response I will get the JSON array.</p>
  
  <p>I am getting the response but my <code>ArrayList</code> shows error </p>
  
  <p><code>statuslist ='this' is not available</code></p>
  
  <p>Below is my code of .</p>
  
  <pre><code>private ArrayList&lt;Main_lead_data&gt; statusList = new ArrayList&lt;&gt;();
  private RecyclerView mainleadRecycler;
  private Main_lead_Adpater mainleadRecycler_Adpter;
  
      mainleadRecycler = findViewById(R.id.idRecyclerViewHorizontalList);
      mainleadRecycler.addItemDecoration(new DividerItemDecoration(MainActivity.this, LinearLayoutManager.HORIZONTAL));
      mainleadRecycler_Adpter = new Main_lead_Adpater(this,statusList);
      LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false);
      mainleadRecycler.setLayoutManager(horizontalLayoutManager);
      mainleadRecycler.setAdapter(mainleadRecycler_Adpter);
  
    public void getLeadStatus(){
  
      final ProgressDialog progressBar = new ProgressDialog(MainActivity.this);
      progressBar.setMessage("Loading..");
      progressBar.show();
      RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
      StringRequest stringRequest = new StringRequest(Request.Method.POST,leadstatus_url,
              new com.android.volley.Response.Listener&lt;String&gt;() {
                  @Override
                  public void onResponse(String response) {
                      if(!response.isEmpty()){
                          try {
                              JSONArray jsonarray=new JSONArray(response);
                            statusList =new ArrayList&lt;Main_lead_data&gt;();
  
                              for(int i=0;i&lt;jsonarray.length();i++)
                              {
                                  JSONObject jsonobject = jsonarray.getJSONObject(i);
  
                                  Main_lead_data data=new Main_lead_data();
  
                                  data.setStatusName((jsonobject.optString("name")));
                                  data.setStatusCount(jsonobject.optString("data"));
                                  data.setStaus_id(jsonobject.optString("sid"));
  
                                  statusList.add(data);
                              }
  
                              progressBar.dismiss();
                          } catch (JSONException e) {
                              progressBar.dismiss();
                              Toast.makeText(MainActivity.this,"Server Not Responding..Please Try Again",Toast.LENGTH_SHORT).show();
                              Log.e("catchException",e.toString());
                              e.printStackTrace();
                          }
                      }
                      else {
                          progressBar.dismiss();
                          Toast.makeText(MainActivity.this,"Server Not Responding",Toast.LENGTH_SHORT).show();
                          Log.e("error","Empty Response");
                      }
                  }
              },
              new com.android.volley.Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      Log.e("error",error.toString());
                      progressBar.dismiss();
                      Toast.makeText(MainActivity.this,"Server Not Responding",Toast.LENGTH_SHORT).show();
                  }
              }) {
          @Override
          protected Map&lt;String, String&gt; getParams() {
              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("company_id",companyId );
  
              return params;
          }
      };
  
      requestQueue.add(stringRequest);
  }
  </code></pre>
  
  <p>I also want to know how to pass post params in JsonArrayRequest method and get response.</p>
  
  <p>Below is the adapter class:</p>
  
  <pre><code>public class Main_lead_Adpater extends RecyclerView.Adapter&lt;Main_lead_Adpater.ViewHolder&gt; {
      private Context context;
      private ArrayList&lt;Main_lead_data&gt; lead_data ;
      LinearLayout view_linear;
  
      public Main_lead_Adpater(Context context,ArrayList&lt;Main_lead_data&gt; lead_data) {
          this.context = context;
          this.lead_data=lead_data;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.main_lead_item, parent, false);
          ViewHolder viewHolder = new ViewHolder(v);
          return new ViewHolder(v);
      }
  
      @Override
      public void onBindViewHolder(final ViewHolder holder, int position) {
          Main_lead_data lead_status = lead_data.get(position);
  
          holder.textCount.setText(lead_status.getStatusCount());
          holder.textName.setText(String.valueOf(lead_status.getStatusName()));
          holder.textId.setText(String.valueOf(lead_status.getStaus_id()));
  
          view_linear.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
              }
          });
      }
  
      @Override
      public int getItemCount() {
          return lead_data.size();
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          public TextView textCount, textName, textId;
  
          public ViewHolder(View itemView) {
              super(itemView);
  
              textCount = itemView.findViewById(R.id.total_count);
              textName = itemView.findViewById(R.id.status_name);
              textId = itemView.findViewById(R.id.sid_tv);
              view_linear=(LinearLayout)itemView.findViewById(R.id.view_linear);
  
          }
      }
  }
  </code></pre>
  
  <p>Below is the JSON response:</p>
  
  <pre><code>[
  {
      "name": "New Enquiry",
      "data": "23",
      "sid": "1"
  },
  {
      "name": "Interested",
      "data": "4",
      "sid": "2"
  },
  {
      "name": "Not Interested",
      "data": "5",
      "sid": "3"
  },
  {
      "name": "Proposal Sent",
      "data": "5",
      "sid": "4"
  },
  {
      "name": "Ongoing",
      "data": "8",
      "sid": "6"
  },
  {
      "name": "Converted Client",
      "data": "6",
      "sid": "7"
  },
  {
      "name": "Lost",
      "data": "27",
      "sid": "8"
  }]
  </code></pre>
  
  <p>Thanks.</p>