Sabyasachi Sahu
Sabyasachi Sahu

Reputation: 33

No Adapter Attached Skipping layout error with RecyclerView Adapter

These are steps I am doing in this project:

The ArrayList Activity file:

As you can see that the RecyclerView is called fine, but the ArrayList is not loading.

The Error: E/RecyclerView: No adapter attached; skipping layout

I referred to various posts in Stackoverflow and followed the steps, not sure where I am going wrong.

I am adding screenshots here of the Arraylist file: enter image description here

The RecyclerView adapter: enter image description here

enter image description here

enter image description here

Upvotes: 1

Views: 227

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138969

You are getting the following warning, not an error:

E/RecyclerView: No adapter attached; skipping layout

Because you are setting the adapter in a background thread. To solve this, you have to set the adapter outside the callback and inside it, just notify it about the changes. So please move the following lines of code:

journalRecyclerAdapter= new JournalRecyclerAdapter(JournalListActivity.this, journalist);
recyclerView.setAdapter(journalRecyclerAdapter);

Right after:

super.onStart();

And leave the following line as it is inside the callback:

journalRecyclerAdapter.notifyDataSetChanged();

And the warning will disapear.

Upvotes: 1

Related Questions