I have a custom view extending a TextView
. Where should I call my component to inject the view?
component.inject(customTextView);
So, I've find out that I need to add the injection in the constructor of my custom view (in all of them, or make one call the other)
Example:
public class CustomTextView extends TextView {
@Inject
AnyProvider anyProvider;
public CustomTextView(Context context) { this(context, null); }
public CustomTextView(Context AttributeSet attrs) {
super(context, attrs);
Application.getComponent(context).inject(this);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With