title: ReyclerView. Police Data Json - No adapter attached, skipping layout
body: <p>Good afternoon guys, I am trying to fetch some data from the police data website. </p>
  
  <p>Unfortunately, the application doesn't show any data saying "<strong>E/<code>RecyclerView</code>: No adapter attached; skipping layout</strong>".</p>
  
  <p>I have attached the <code>LatestCrimesActivity</code>, adapter and the <code>ListItem</code> class. </p>
  
  <p>Thank you for your help. </p>
  
  <p>This is <code>LatestCrimesActivity</code>:</p>
  
  <pre><code>package com.example.cosmin.crimerate.Latest_crimes_api;
  
  import android.app.ProgressDialog;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  
  import com.android.volley.Request;
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.android.volley.toolbox.Volley;
  import com.example.cosmin.crimerate.R;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class LatestCrimesActivity extends AppCompatActivity {
      private static final String URL_DATA = "https://data.police.uk/api/crimes-street/all-crime?poly=52.268,0.543:52.794,0.238:52.130,0.478&amp;date=2017-01";
  
      private RecyclerView recyclerView;
      private RecyclerView.Adapter adapter;
  
      private List&lt;ListItem&gt; listItems;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_latest_crimes);
  
          recyclerView = (RecyclerView) findViewById(R.id.recyclerViewlatest);
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
  
  
          listItems=new ArrayList&lt;&gt;();
  
          loadRecyclerViewData();
  
  
          }
  
      private void loadRecyclerViewData() {
  
          final ProgressDialog progressDialog = new ProgressDialog(this);
          progressDialog.setMessage("Loading data...");
          progressDialog.show();
  
          StringRequest stringRequest = new StringRequest(Request.Method.GET,
                  URL_DATA,
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String s) {
                          progressDialog.dismiss();
                          try {
                              JSONObject jsonObject = new JSONObject(s);
                              JSONArray array = jsonObject.getJSONArray("");
  
                              for (int i=0; i&lt;array.length();i++){
                                  JSONObject o = array.getJSONObject(i);
  
                                  ListItem item = new ListItem(
                                          o.getString("category"),
                                          o.getString("location_type"),
                                          o.getString("street"),
                                          o.getString("status")
                                  );
                                  listItems.add(item);
  
                              }
                              adapter = new MyAdapter(listItems, getApplicationContext());
                              recyclerView.setAdapter(adapter);
  
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError volleyError) {
  
                      }
                  });
  
          RequestQueue requestQueue = Volley.newRequestQueue(this);
          requestQueue.add(stringRequest);
      }
  
  
  }
  </code></pre>
  
  <p>Adapter:</p>
  
  <pre><code>package com.example.cosmin.crimerate.Latest_crimes_api;
  
  import android.content.Context;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Adapter;
  import android.widget.TextView;
  
  import com.example.cosmin.crimerate.R;
  
  import java.util.List;
  
  /**
   * Created by Cosmin on 25/11/2017.
   */
  
  public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt; {
  
  
  
      private List&lt;ListItem&gt; listItems;
  
      private Context context;
  
      public MyAdapter(List&lt;ListItem&gt; listItems, LatestCrimesActivity latestCrimesActivity) {
          this.listItems = listItems;
          this.context = context;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.list_item, parent, false);
          return new ViewHolder(v);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          ListItem listItem = listItems.get(position);
  
          holder.textViewCat.setText(listItem.getCategory());
          holder.textViewLoc.setText(listItem.getLocation());
          holder.textViewStreet.setText(listItem.getStreet());
          holder.textViewStatus.setText(listItem.getStatus());
  
  
      }
  
      @Override
      public int getItemCount() {
  
          return listItems.size();
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder{
  
          public TextView textViewCat;
          public TextView textViewLoc;
          public TextView textViewStreet;
          public TextView textViewStatus;
  
  
          public ViewHolder(View itemView) {
  
              super(itemView);
  
              textViewCat = (TextView) itemView.findViewById(R.id.textViewCat);
              textViewLoc = (TextView) itemView.findViewById(R.id.textViewLoc);
              textViewStreet = (TextView) itemView.findViewById(R.id.textViewStreet);
              textViewStatus = (TextView) itemView.findViewById(R.id.textViewStatus);
  
          }
      }
  }
  </code></pre>
  
  <p>This is <code>ListItem</code> class:</p>
  
  <pre><code>package com.example.cosmin.crimerate.Latest_crimes_api;
  
  /**
   * Created by Cosmin on 25/11/2017.
   */
  
  public class ListItem {
  
      private String category;
      private String location;
      private String street;
      private String status;
  
      public ListItem (String category, String location, String street, String status){
          this.category=category;
          this.location=location;
          this.street=street;
          this.status=status;
      }
      public String getCategory (){
          return category;
      }
      public String getLocation (){
          return location;
      }
      public String getStreet (){
          return street;
      }
      public String getStatus (){
          return status;
      }
  
  }
  </code></pre>