You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.rehome.zhdcoa.base
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.rehome.zhdcoa.databinding.AdapterItemInfoBinding
/**
* Create By HuangWenFei
* 创建日期: 2024-07-03 14:39
* 描述: BaseViewBindingKotlinAdapter
*/
class ItemInfoAdapter ( val infoList : List < String > ) : RecyclerView . Adapter < ItemInfoAdapter . ViewHolder > ( ) {
private lateinit var mBinding : AdapterItemInfoBinding
//2.继承类中传入binding.root, 然后根据binding获取item中的view
inner class ViewHolder ( binding : AdapterItemInfoBinding ) : RecyclerView . ViewHolder ( binding . root ) {
val tvInfo : TextView = binding . tvXh
}
override fun onCreateViewHolder ( parent : ViewGroup , viewType : Int ) : ViewHolder {
//1.获取ItemInfoBinding
mBinding = AdapterItemInfoBinding . inflate ( LayoutInflater . from ( parent . context ) , parent , false )
return ViewHolder ( mBinding )
}
override fun onBindViewHolder ( holder : ViewHolder , position : Int ) {
holder . tvInfo . text = infoList [ position ]
}
override fun getItemCount ( ) : Int = infoList . size
}