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()
:
@Override
protected void onCreate(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 = new Adapter(this,getData());
recyclerView.setLayoutManager(new LinearLayoutManager(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:
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{View view = inflater.inflate(R.layout.meme_item, parent, false);
MyViewHolder holder = new MyViewHolder(view);
return view;}
return view on here instead of return null
Post a Comment for "No Adapter Attached; Skipping Layout OnCreateView()"