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

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

概述

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

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

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

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

  1. 下載新的 RoboGuice 庫(kù),Roboguice2.0 庫(kù)有四個(gè)庫(kù)組成,如下圖所示:

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

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

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

  2. 如果你使用了自定義的 Module 來(lái)定義 Bindings,在2.0中可以通過(guò) XML 來(lái)定義,比如在 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 ,去除原來(lái)定義的 RoboApplication 派生類定義,并在代碼中去除 RoboApplication 派生類定義。

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

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