ribot / easy-adapter

[DEPRECATED] Easy Adapters library for Android
http://ribot.github.io
Apache License 2.0
421 stars 50 forks source link

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

Open janoliver opened 9 years ago

janoliver commented 9 years ago

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 commented 9 years ago

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.