Recyclerview not call onCreateViewHolder

前端 未结 30 1401
离开以前
离开以前 2020-11-28 07:04

My RecyclerView does not call onCreateViewHolder, onBindViewHolder even MenuViewHolder constructor, therefore nothing app

30条回答
  •  执念已碎
    2020-11-28 07:49

    I really really hope this helps someone someday. I just spend over an hour on this one going nuts!

    I had this:

    projects_recycler_view.apply {
                this.layoutManager = linearLayoutManager
                this.adapter = adapter
            }
    

    When I should have had this:

    projects_recycler_view.apply {
                this.layoutManager = linearLayoutManager
                this.adapter = projectAdapter
            }
    

    Because I foolishly called my adapter adapter, it was being shadowed by the recycler view's adapter in the apply block! I renamed the adapter to projectAdapter to differentiate it and problem solved!

提交回复
热议问题