Issue
I got a parent layout, activity_main.xml
, with multiple views inside it, one of which is the RecyclerView
view.
Within the recycler view, there are buttons that, once the user deals with them, 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.
What might be the best practices for such cases?
Solution
You need to create an interface callback or use a higher-order function.
This Stack Overflow answer is an example of an interface callback: How to access component of MainActivity in recycler view to make onclick listener?.
Kotlin Lambda Functions For RecyclerView Adapter Callbacks in Android is for higher-order functions.
Answered By - Ashutosh Ojha
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.