title: No adapter attached, skipping layout in RecyclerView
body: <p>My recyclerView turns out to be blank when i try to load data from JSON.
  In logcat, it says, "No adapter attached; skipping layout"</p>
  
  <p>This is my activity</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private RecyclerView news;
  private RecyclerView.Adapter news_adapter;
  private List&lt;News_Item&gt; listItems;
  private static final String news_data = "Url to Json file";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      news = (RecyclerView) findViewById(R.id.news);
      news.setHasFixedSize(true);
      news.setLayoutManager(new LinearLayoutManager(this));
  
      listItems = new ArrayList&lt;&gt;();
      loadRecyclerViewData();
  
  }
  
  private void loadRecyclerViewData(){
      final ProgressDialog progressDialog = new ProgressDialog(this);
      progressDialog.setMessage("Loading News...");
      progressDialog.show();
  
      StringRequest stringRequest = new StringRequest(Request.Method.GET,
              news_data,
              new Response.Listener&lt;String&gt;() {
                  @Override
                  public void onResponse(String response) {
                      progressDialog.dismiss();
                      try {
                          JSONObject jsonObject = new JSONObject(response);
                          JSONArray array = jsonObject.getJSONArray("articles");
  
                          for(int i = 0; i &lt; array.length(); i++){
                              JSONObject o = array.getJSONObject(i);
                              News_Item item = new News_Item(
                                      o.getString("title"),
                                      o.getString("description"),
                                      o.getString("author"),
                                      o.getString("urlToImage"),
                                      o.getString("URL")
                              );
  
                              listItems.add(item);
                          }
  
                          news_adapter = new News_Adapter(listItems,getApplicationContext());
                          news.setAdapter(news_adapter);
  
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
              }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              progressDialog.dismiss();
              Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
          }
      });
  
      RequestQueue requestQueue = Volley.newRequestQueue(this);
      requestQueue.add(stringRequest);
  }
  }
  </code></pre>
  
  <p>But it works fine when i load dummy data in it as follow</p>
  
  <pre><code> listItems = new ArrayList&lt;&gt;();
  
      for(int i= 0; i&lt;=10 ; i++){
          News_Item news_item = new News_Item(
                  "Heading" + (i+1),
                  "Lorem Ipsum",
                  "Lorem Ipusm",
                  "Lorem Ipsum",
                  "Lorem Ipsum"
          );
          listItems.add(news_item);
      }
      news_adapter = new News_Adapter(listItems,this);
      news.setAdapter(news_adapter);
  </code></pre>
  
  <p>I tried to read some other questions on here on stackoverflow, but most of them did't helped <a href="https://stackoverflow.com/questions/37202720/no-adapter-attached-skipping-layout-recyclerview">question 1</a>,<br>
  <a href="https://stackoverflow.com/questions/29141729/recyclerview-no-adapter-attached-skipping-layout">question 2</a>, 
  <a href="https://stackoverflow.com/questions/30895580/recyclerview-no-adapter-attached-skipping-layout-for-recyclerview-in-fragmen?rq=1">question 3</a></p>
  
  <p>Here is my News_adapter</p>
  
  <pre><code>public class News_Adapter extends RecyclerView.Adapter&lt;News_Adapter.ViewHolder&gt; {
  
  private List&lt;News_Item&gt; listItems;
  private Context context;
  
  public News_Adapter(List&lt;News_Item&gt; listItems, Context context) {
      this.listItems = listItems;
      this.context = context;
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.card,parent,false);
  
      return new ViewHolder(v);
  
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
      final News_Item item = listItems.get(position);
  
      holder.news_title.setText(item.getTitle());
      holder.news_desc.setText(item.getSubtitle());
      holder.news_author.setText(item.getAuthor());
  
      Picasso.with(context)
      .load(item.getImg_url())
      .into(holder.news_img);
  
      holder.card_body.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Toast.makeText(context, "item clicked "+item.getTitle() , Toast.LENGTH_SHORT).show();
          }
      });
  
  }
  
  @Override
  public int getItemCount() {
      return listItems.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder{
  
      public TextView news_title,news_desc,news_author;
      public ImageView news_img;
      public RelativeLayout card_body;
  
      public ViewHolder(View itemView) {
          super(itemView);
  
          news_author = (TextView) itemView.findViewById(R.id.news_author);
          news_desc = (TextView) itemView.findViewById(R.id.news_desc);
          news_title = (TextView) itemView.findViewById(R.id.news_title);
          news_img = (ImageView) itemView.findViewById(R.id.news_img);
          card_body = (RelativeLayout) itemView.findViewById(R.id.card_body);
  
      }
  }
  
  }
  </code></pre>