在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Android/ 概述
Just-in-time Bindings
Binding Annotations
Standard Injection
第一個例子 Hello World
Bindings 概述
Linked Bindings
如何綁定 generic 類型
@Provides Methods
RoboGuice 功能描述
概述
綜合示例 Astroboy
Inject Resources
Instance Bindings
Inject 自定義 View
Scopes
Provider Bindings
Untargetted Bindings
Inject Extra
第一個例子 Hello World
Inject Context
發(fā)送接收 Events
Inject View

概述

RoboGuice 最近推出了2.0版本。和1.1相比具有:

  • 提高了穩(wěn)定性
  • 支持 Fragment
  • 更簡潔易用

但由于 RoboGuice2 不完全向下兼容 RoboGuice1.1,因此原來使用 RobuGuice1.1 開發(fā)的項目需要對代碼做些修改才可以使用 RoboGuice2.0.

這里主要說明一下使用 Eclipse IDE 開發(fā)環(huán)境升級到 RoboGuice2.0 的一些升級注意事項:

  1. 下載新的 RoboGuice 庫,Roboguice2.0 庫有四個庫組成,如下圖所示:

http://wiki.jikexueyuan.com/project/android-roboguice/images/21.png" alt="" />

庫可以從 http://code.google.com/p/roboguice/ 下載,也可以從本站 下載

  1. 原先1.1中的 RoboApplication 在2.0 已經(jīng)不存在了。2.0使用上更方便,通常的應用如果不是有自定義綁定的話,無需再派生 Application。

  2. 如果你使用了自定義的 Module 來定義 Bindings,在2.0中可以通過 XML 來定義,比如在 res/values/roboguice.xml 定義
<?xml version=”1.0″ encoding=”utf-8″?>

<resources>

<string-array name=”roboguice_modules”>

<item>com.pstreets.guice.demo.GreetingModule</item>

</string-array> </resources>
  1. 原先由 AbstractAndroidModule 派生的類,在2.0中改為 AbstractModule ,如:
ublic class GreetingModule extends AbstractModule {

@Override  protected void configure() {   bind(IGreetingService.class).to(HelloWorld.class);   //bind(IGreetingService.class).to(HelloChina.class);     }

}
  1. 修改 AndroidManifest.xml ,去除原來定義的 RoboApplication 派生類定義,并在代碼中去除 RoboApplication 派生類定義。

以上是主要從 RoboGuice1.1 升級到2.0的主要步驟。在學習2.0之前,可以參考一下1.1的介紹,基本概念還是一樣的。

上一篇:Untargetted Bindings下一篇:Inject Resources