| | |
| | | import java.util.ArrayList |
| | | |
| | | class ReasonAdapter(data: ArrayList<String>) : HFRecyclerAdapter<String>(data, R.layout.item_reason) { |
| | | var checked = -1 |
| | | var checked = arrayListOf<Int>() |
| | | override fun onBind(holder: ViewHolder, position: Int, data: String) { |
| | | holder.bind<TextView>(R.id.tv_reason).apply { |
| | | text = data |
| | | setOnClickListener { |
| | | checked = position |
| | | if (position in checked) |
| | | checked.remove(position) |
| | | else |
| | | checked.add(position) |
| | | notifyDataSetChanged() |
| | | } |
| | | isSelected = position == checked |
| | | isSelected = position in checked |
| | | } |
| | | } |
| | | } |