This question is an exact duplicate of:
There are 5 recyclerview items. When I clicked SelectAll, just first item's checkbox drawable change. I want make all item's checkbox drawable will be change. How to make select all check box work in kotlin??
class CartViewActivity : AppCompatActivity(), SwipeRefreshLayout.OnRefreshListener {
private val tag = this::class.java.simpleName
lateinit var adapter: CartItemRecyclerAdapter
var itemList: MutableList<CartItemDataVo> = arrayListOf()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_cart_view)
SelectAll.setOnClickListener {
if(SelectAll.isChecked){
SelectAll.buttonDrawable=it.context.getDrawable(R.drawable.check_box_active_cs)
checkBox.buttonDrawable=it.context.getDrawable(R.drawable.check_box_active_cs)
else {
SelectAll.buttonDrawable= it.context.getDrawable(R.drawable.check_box_no)
checkBox.buttonDrawable= it.context.getDrawable(R.drawable.check_box_no)
}
}
swipeRefreshLo.setOnRefreshListener(this)
itemList.add(CartItemDataVo("item1", 1, 16800, "cart_doll"))
itemList.add(CartItemDataVo("item2", 1, 16800, "cart_cup"))
itemList.add(CartItemDataVo("item3", 1, 30000, "cart_perfume"))
itemList.add(CartItemDataVo("item4", 1, 16800, "cart_fan"))
itemList.add(CartItemDataVo("item5", 1, 16800, "cart_bear"))
val itemRecyclerAdapter = CartItemRecyclerAdapter(this, this , itemList)
recycler_view.adapter = itemRecyclerAdapter
recycler_view.layoutManager =
androidx.recyclerview.widget.LinearLayoutManager(applicationContext)
}
override fun onRefresh() {
swipeRefreshLo.isRefreshing = false
}
}
````
Aucun commentaire:
Enregistrer un commentaire