-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Feature Request : Ability to pass Context to ViewHolder in FirebaseRecyclerAdapter #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@chintansoni202 I don't think passing an Activity context to the RecyclerAdapter is the right option in most cases, you have a few options here:
|
Ok @samtstern Can you provide some code snippet demonstrating your points #1, #2 ? For point #1, I am confused if its Fragment and not Activity. For point #2, I am aware of creating interfaces but how would I pass the interface from Activity or Fragment to ViewHolder via my FirebaseRecyclerAdapter ? If you could provide some Github Gist or small code snippet would be much more helpful. |
@chintansoni202 here's a very basic example of how you could use an interface to define this behavior and then pass it from your Activity to the Adapter to the ViewHolder: I am going to close this issue now as we don't plan to add this feature to the library. Good luck! |
@samtstern Thank you so much sir for your Gist. Now, I got your point what you were trying to explain. |
Problem Description: I tried using FirebaseRecyclerAdapter. It has become insanely easy to integrate any type of ListView or RecyclerView with any complex views inside its list item. I came across a thing I would like to describe.
I had buttons and other controls in Recycler Item; I set the ClickListeners to Buttons inside ViewHolder itself. Now, I want to use Activity context inside my ViewHolder class. So, I went creating my own class same as FirebaseRecyclerAdapter as below:
TodoViewHolder.java
And MyFirebaseAdapter.java
But I get following exception:
The issue is explained on http://stackoverflow.com/questions/38429054/firebaserecycleradapter-pass-activity-context-to-viewholder by @puf
So, thought this might be good if we are able to pass Activity Context to ViewHolders.
The text was updated successfully, but these errors were encountered: