java.lang.NullPointerException at android.support.v7.widget.RecyclerView.onMeasure

后端 未结 5 514
梦毁少年i
梦毁少年i 2020-12-06 04:20

I try to use RecyclerView with RecyclerView.Adapter but here is something wrong. I post my code below:

Layout:

   

        
5条回答
  •  悲哀的现实
    2020-12-06 04:56

    I got this error when my RecyclerView had no LayoutManager. Adding this code fixed the problem:

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

提交回复
热议问题