recyclerview No adapter attached; skipping layout

后端 未结 30 3070
走了就别回头了
走了就别回头了 2020-11-21 04:51

Just implemented RecyclerView in my code, replacing ListView.

Everything works fine. The data is displayed.

But error messages are

30条回答
  •  孤街浪徒
    2020-11-21 05:14

    ArtistArrayAdapter adapter = new ArtistArrayAdapter(this, artists);
    recyclerView = (RecyclerView) findViewById(R.id.cardList);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    

    Just replace above code with this and it should work. What you did wrong is you called setAdapter(adapter) before calling layout manager.

提交回复
热议问题