@EActivity(R.layout.data_layout)
public class MyActivity extendsActivity
{
@Bean MyEbean bean;
@AfterViews
public void setupView()
{
bean.loadData("Test name");
}
}
@EBean public class MyEbean
{
@RootContext context;
@ViewById(R.id.name_field)
TextView nameField;
public void loadData(String name)
{
nameField.setText(name);
}
}
"名称字段" in loadData()为null。同时如果我在loadData()
中执行此操作nameField = (TextView)((Activity)context).findViewById(R.id.name_field); it's all good. So the view isdefinitely there. Also if I call this method from a retrofit callback
(即延迟后)"姓名"是自动填充的。
我正在使用Android Annotations 3.3.2
答案 0 :(得分:1)
我不知道它为什么不起作用,但如果你需要它只是有效,解决方案很简单:
@EActivity(R.layout.data_layout)
public class MyActivity extends Activity {
@Bean MyEbean bean;
}
@EBean
public class MyEbean {
@ViewById Button previewButton;
@AfterViews void init() {
previewButton.setText("Blah");
}
}
答案 1 :(得分:0)
- 同意以上回答
关键点是....
@AfterViews void init() {
previewButton.setText("Blah");
}