Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有一个函数的辅助类,它接收一个活动作为参数。我想从该活动中注入一个视图。这可能吗?
public class myClass { public void myMethod(final Activity activity) { // Use here a TextView from that activity - how to inject it?
提前致谢!
将其作为类的字段注入。您不能直接注入方法体。
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"); } }