Get list of checked checkboxes from recyclerview android

前端 未结 7 1504
慢半拍i
慢半拍i 2020-12-24 02:40

I have populated the recyclerView with image, title and checkbox. I have two problems.

  1. How to make the checkbox selected when the imageview or the whole rec

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 03:32

    from @ninjahoahong I add checkbox listenner in onBindViewHolder method and checkbox can click able.

    viewHolder.checkBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int pos = viewHolder.getAdapterPosition();
            ChoiceItem currentItem = mChoice.get(pos);
            if(viewHolder.checkBox.isChecked()){
                onItemCheckListener.onItemCheck(currentItem);
                currentItem.setCheck(true);
            }else{
                onItemCheckListener.onItemUncheck(currentItem);
                currentItem.setCheck(false);
            }
        }
    });
    

提交回复
热议问题