RecyclerView﹕ No adapter attached; skipping layout

前端 未结 3 917
南旧
南旧 2020-12-03 19:00

I have been reading the different answers here on stackoverflow and on this blog post and tried to implement their solutions but I am still getting the error:

相关标签:
3条回答
  • 2020-12-03 19:42

    I never had this issue and it was really hard to replicate for me.

    0 讨论(0)
  • 2020-12-03 19:42

    make sure you have set LayoutManager to RecyclerView. Hope it will help :)

    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    list.setLayoutManager(llm);
    list.setAdapter( adapter );
    
    0 讨论(0)
  • 2020-12-03 19:43

    You're getting the error because you set the adapter when the data source (photoList) is still empty. and also saying to your recycler view that it's size will not change (by calling setHasFixedSize(true)) but you ARE changing the size of the list in the onCompletion callback of the query. So, remove setHasFixedSize(true) and it should work once you populate the list.

    EDIT: I was wrong, the size in the method has nothing to do with data but with the size of the recycler view itself.

    0 讨论(0)
提交回复
热议问题