Skip to content Skip to sidebar Skip to footer

No Adapter Attached; Skipping Layout Oncreateview()

Trying to implement RecyclerView into my application, I don't understand why i'm getting 'No adapter attached; skipping layout' I thought i clearly set it up in the onCreateView. S

Solution 1:

Try move the code in onCreateView() method of your Activity to onCreate():

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);

    recyclerView = (RecyclerView) findViewById(R.id.meme_list);
    adapter = newAdapter(this,getData());
    recyclerView.setLayoutManager(newLinearLayoutManager(this));
    recyclerView.setAdapter(adapter);

}

You also need to return ViewHolder as @Yasin KaƧmaz 's answer.

Solution 2:

Can you try this. I looked my working recycler view code and found this difference:

@Overridepublic MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) 

{Viewview= inflater.inflate(R.layout.meme_item, parent, false);
MyViewHolderholder=newMyViewHolder(view);
return view;}

return view on here instead of return null

Post a Comment for "No Adapter Attached; Skipping Layout Oncreateview()"