Skip to content
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

More arguments for the constructor of the ViewHolder class? #41

Open
janoliver opened this issue Oct 11, 2015 · 1 comment
Open

More arguments for the constructor of the ViewHolder class? #41

janoliver opened this issue Oct 11, 2015 · 1 comment

Comments

@janoliver
Copy link

Hi, I can't seem to figure out how to access a variable or function of the fragment containing my ViewHolder class.

Since the constructor has to have a single View parameter, how can I access my fragment in my (static) ViewHolder implementation?

Thank you for the work!

@ivacf
Copy link
Contributor

ivacf commented Oct 12, 2015

Hi, you won't be able to access any variable or method in your fragment from a static inner class. I recommend you to keep your ViewHolder decoupled from the Fragment so it's reusable.

If you want to call a method in the fragment from the ViewHoder when something happens, you can achieve this via callback/listener. See this section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants