androidandroid-recyclerviewexpandablerecyclerview

Fix error RecyclerView: No adapter attached; skipping layout


Just implemented RecyclerView in my code, replacing ListView.

Everything works fine. The data is displayed.

But error messages are being logged:

RecyclerView: No adapter attached; skipping layout

I have read other questions related to the same problem but none of them help.


Solution

  • i have this problem , a few time problem is recycleView put in ScrollView object

    After checking implementation, the reason appears to be the following. If RecyclerView gets put into a ScrollView, then during measure step its height is unspecified (because ScrollView allows any height) and, as a result, gets equal to minimum height (as per implementation) which is apparently zero.

    You have couple of options for fixing this:

    Set a certain height to RecyclerView Set ScrollView.fillViewport to true Or keep RecyclerView outside of ScrollView. In my opinion, this is the best option by far. If RecyclerView height is not limited - which is the case when it's put into ScrollView - then all Adapter's views have enough place vertically and get created all at once. There is no view recycling anymore which kinda breaks the purpose of RecyclerView . (Can be followed for android.support.v4.widget.NestedScrollView as well)