0

Select and Unselect items in recyclerview without using any checkbox or radio button or etc.

  • I want to select 1st recyclerview item on longclick and then all the other item on single click in recyclerview list.
  • Unselect item on single click as well on recyclerview list.

UPDATE()

    holder.itemView.setOnLongClickListener(View.OnLongClickListener {

                    if (selectedPosition == position) {
                        selectedPosition = -1
                        notifyItemChanged(position);
                    }
                    selectedPosition = position;
                    notifyItemChanged(position);}

After one long click i want to select and unselect item only on single click

  • Have a look to this: [https://developer.android.com/topic/architecture/ui-layer/events#recyclerview-events](https://developer.android.com/topic/architecture/ui-layer/events#recyclerview-events) – remarcoble Jul 04 '22 at 09:17
  • 1
    RecyclerView provides selection tracker for this purpose. Check this out https://developer.android.com/reference/androidx/recyclerview/selection/package-summary – Ravi Mishra Jul 04 '22 at 10:48
  • @RaviMishra Code snippet what i am doing here and written down what i needed. Can you provide me with a solution as of documentation i am not able to understand clearly – Prateek Sharma Jul 05 '22 at 06:26

0 Answers0