RecyclerView item not showing ripples/touch feedback when the item has a checkbox

前端 未结 3 1473
慢半拍i
慢半拍i 2021-01-12 19:11

I want the items in a RecyclerView to have touch feedback or ripples when pressed, but they seem to not be working, and I think it\'s because of the checkbox.

The ri

3条回答
  •  旧时难觅i
    2021-01-12 20:10

    In your onClick method (assuming in your callback), make sure you do not call notifyDataSetChanged() after notifyItemChanged(position).

    notifyDataSetChanged() will conflict with those default ripple effects.

    new recyclerAdapter.ClickListener() {
        @Override
        public void onClick(int position) {
    
            ... awesome item onClick code ...
    
            notifyItemChanged(position);
            //notifyDataSetChanged(); 

提交回复
热议问题