How to bind view in RecyclerView.ViewHolder with kotlin

后端 未结 3 1251
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 03:35

What makes me puzzled is how to bind view in Recycleler.ViewHolder. This is my simple adapter and how to Convert it to kotlin use kotlin-android-extensio

3条回答
  •  甜味超标
    2020-12-15 04:29

    Others answered the question quite well, I just wanted to add that in class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) there should be no nullable operator ('?') after itemView for kotlin binding to work.

    Android Studio automatically adds that nullable operator when using autocomplete for adding constructer parameters from ViewHolder(itemView).

提交回复
热议问题