Add a Button to a Recycler View in Android Kotlin

Опубликовано: 27 Июль 2026
на канале: Brandan Jones
9,810
56

In this video I show how to add a button (delete button, in this case) to an existing RecyclerView in an existing Android application.

I take these steps:
0) Review an animation on how RecyclerViews work, because it's complicated!
1) Add a delete function to the ViewModel class, which will delete the item from Firebase Cloud Firestore.
2) Create a delete icon to add to an ImageButton.
3) Add an ImageButton to the row layout of the recycler view, and attach the image created in a previous step to that button.
4) In the ViewHolder, setOnClickListener on to the button, so that it can process click events.
5) Create a function in the enclosing class that will be invoked when the onClickListener is invoked.
6) Have this new function invoke the delete function I created in the ViewModel in an earlier step.
7) Walk through the entire process in the debugger, so that you can see how this button deletes a single event in the Firebase database.

This video is part of a playlist, available at:    • Learning Module 2 3048 Q  

All source code is freely available on GitHub, at: https://github.com/discospiff/MyPlant...