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.
|
|
|
|
|
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
|
|
|
|
|
|
}
|