Guice 是一个依赖项注入(DI)基于Java的框架,RoboGuice 为Android平台上基于Google Guice开发的一个库。
2014-05-13 17:26:09
下载地址:
https://github.com/roboguice/roboguice
RoboGuice 为Android平台上基于Google Guice开发的一个库,可以大大简化Android应用开发的代码和一些繁琐重复的代码。
原先:
TextView login_username= (TextView) findViewById(R.id.login_username);
现在:
@InjectView(R.id.login_username) TextView login_username;
简便了很多!
使用RoboGuice时,需要
import roboguice.activity.RoboActivity;
import roboguice.inject.InjectView;
并且让Activity继承RoboActivity。
在Fragment下也能用!