Back

Android: 使用 @ViewInject 来替代 findViewById

发布时间: 2016-08-31 00:54:00

如果你在android 项目中看到这样的代码: 

// 变量声明中
@ViewInject(R.id.textView_dialog)
private TextView textView_dialog;


// onCreate方法中:
ViewUtils.inject(this);


不用慌, 它就等同于: 

private TextView textView_dialog;
//...
textView_dialog = (TextView)findViewById(R.id.textView_dialog);

Back