recyclerview No adapter attached; skipping layout

后端 未结 30 3092
走了就别回头了
走了就别回头了 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:12

    This issue is because you are not adding any LayoutManager for your RecyclerView.

    Another reason is because you are calling this code in a NonUIThread. Make sure to call this call in the UIThread.

    The solution is only you have to add a LayoutManager for the RecyclerView before you setAdapter in the UI Thread.

    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    

提交回复
热议问题