Search code examples
androidandroid-recyclerviewviewandroid-viewonlongclicklistener

How to display all hidden checkoboxes in a recyclerview on long press?


I made a layout for an item, with a hidden checkbox. On a long press, I want to make all checkboxes for all item in the recyclerview visible. I've tried to implement a long click listener but on a long press of an item only the check box for this specific item becomes visible.


Solution

    • Adapter has 1 boolean to control visibility of checkbox in all items. If it is false, hide checkbox of the rows and vise versa
    • When user long clicks on 1 item, change this boolean to true
    • Right after that, call notifyDataSetChanged
    • The list will display all checkboxes