RoboGuice 最近推出了2.0版本。和1.1相比具有:
但由于 RoboGuice2 不完全向下兼容 RoboGuice1.1,因此原來使用 RobuGuice1.1 開發(fā)的項目需要對代碼做些修改才可以使用 RoboGuice2.0.
這里主要說明一下使用 Eclipse IDE 開發(fā)環(huán)境升級到 RoboGuice2.0 的一些升級注意事項:
http://wiki.jikexueyuan.com/project/android-roboguice/images/21.png" alt="" />
庫可以從 http://code.google.com/p/roboguice/ 下載,也可以從本站 下載
原先1.1中的 RoboApplication 在2.0 已經(jīng)不存在了。2.0使用上更方便,通常的應用如果不是有自定義綁定的話,無需再派生 Application。
<?xml version=”1.0″ encoding=”utf-8″?>
<resources>
<string-array name=”roboguice_modules”>
<item>com.pstreets.guice.demo.GreetingModule</item>
</string-array> </resources>
ublic class GreetingModule extends AbstractModule {
@Override protected void configure() { bind(IGreetingService.class).to(HelloWorld.class); //bind(IGreetingService.class).to(HelloChina.class); }
}
以上是主要從 RoboGuice1.1 升級到2.0的主要步驟。在學習2.0之前,可以參考一下1.1的介紹,基本概念還是一樣的。