I got a parent layout activity_main.xml
layout with multiple views inside it, one of which is the RecyclerView
view.
What happens is that, within the recycler view, there are buttons that, once the user deals with, I would like things to happen in the parent layout that is activity_main.xml
.
For example, if I press a button on a ViewHolder
item inside the child RecyclerView
, in some cases, I would like changes to happen in the parent activity_main.xml
layout.
However, my problem is that I don't know how to allow for this communication to happen.
Any suggestions on what might be the best practices for such cases?
CodePudding user response:
You need to create Interface callback or use higher order function. This link is an example of interface callback How to access component of MainActivity in recycler view to make onclick listener? This link is for higher order function https://www.geeksforgeeks.org/kotlin-lambda-functions-for-recyclerview-adapter-callbacks-in-android/