lmw
2023-06-13 adf8013576cbdd12e5ebea8ff7e32baf5d558b27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.kuanzhai.user.ui.official.adapter
 
import android.widget.TextView
import cn.sinata.xldutils.adapter.HFRecyclerAdapter
import cn.sinata.xldutils.adapter.util.ViewHolder
import com.kuanzhai.user.R
import java.util.ArrayList
 
class ReasonAdapter(data: ArrayList<String>) : HFRecyclerAdapter<String>(data, R.layout.item_reason) {
    var checked = arrayListOf<Int>()
    override fun onBind(holder: ViewHolder, position: Int, data: String) {
        holder.bind<TextView>(R.id.tv_reason).apply {
            text = data
            setOnClickListener {
                if (position in checked)
                    checked.remove(position)
                else
                    checked.add(position)
                notifyDataSetChanged()
            }
            isSelected = position in checked
        }
    }
}