From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Support selecting RecyclerView items

Support selecting RecyclerView items - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Support selecting RecyclerView items

- [Instructor] In past versions of plain node notes, you had to open a note in the editor to delete it. In this version, I'm going to let the user select nodes in the main fragment, and then delete the notes that are selected. I'll need to manage a collection of selected notes in memory. And I'm going to do that in my adapter class, notes list adapter. First, I'll clean up this code a bit. I'll get rid of this extra line feed. And then I'll declare a new persistent variable that I'll name selected notes. And this will be an array list. I'll use Kotlin's array list of function and I'll set the type of the array list items to note entity. And it will start off as empty. Now go down to my on bind view holder function. I'm going to set up a click listener. Now let's take a look at the XML layout file I'm working with here. There's a floating action button and it has an ID of floating action button. I'm going to…

Contents