Skip to content Skip to sidebar Skip to footer

Setlayoutmanager Nullpointexception In Recyclerview

I'm trying to receive a list with an array in RecyclerView and get error: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.Recycler

Solution 1:

As @StenSoft noted in comments the problem was in setContentView (R.layout.activity_main_appbar); because of wrong activity layout content, instead of setContentView (R.layout.activity_main);

Solution 2:

In my case this error comes because I did not create RecyclerView in one of my activity .

check your activity layout or fragment layout.

Solution 3:

I had something similar ,but in kotlin and inside the

RecyclerView.apply {} 

code, in the line :

layoutManager = viewManager

eventually I found out it was because I inflated the wrong layout to the fragment, in the line:

return inflater.inflate(R.layout.main_fragment, container, false)

Post a Comment for "Setlayoutmanager Nullpointexception In Recyclerview"