0

I've a helper class with one function, that receives an activity as a parameter. I want to inject a view from that activity. Is this possible?

public class myClass {
   public void myMethod(final Activity activity) {
      // Use here a TextView from that activity - how to inject it?

Thanks in advance!

Jan Galinski
  • 11,768
  • 8
  • 54
  • 77
nano
  • 2,511
  • 4
  • 25
  • 42

1 Answers1

0

Inject it as a field of the class. You can't inject directly into a method body.

public class myClass {
    @InjectView(R.id.myTextView)
    private TextView myTextView;
    public void myMethod(final Activity activity) {
        // Use here a TextView from that activity - how to inject it?
        myTextView.setText("something");
    }
}
Jeroen
  • 3,399
  • 1
  • 22
  • 25