Recyclerview not call onCreateViewHolder

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

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

30条回答
  •  粉色の甜心
    2020-11-28 07:37

    Make sure your XML and Koltin/Java code match. In my case, I had a problem with the ViewHolder since I had written:

    var txt: AppCompatTextView = itemView.findViewById(R.id.txt)
    

    But since my XML code is:

    
    

    I had to change the privious row into:

    var txt: TextView = itemView.findViewById(R.id.txt)
    

    In addition, I also had to remove:

    recyclerView.setHasFixedSize(true);
    

    I hope this can help you :)

提交回复
热议问题