0

我有一个带有一个函数的辅助类,它接收一个活动作为参数。我想从该活动中注入一个视图。这可能吗?

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

提前致谢!

4

1 回答 1

0

将其作为类的字段注入。您不能直接注入方法体。

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");
    }
}
于 2013-08-02T12:15:41.510 回答