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

鍍金池/ 教程/ Android/ RoboGuice 功能描述
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 功能描述

前面在 Android RoboGuice 使用指南(1):概述 對應(yīng) Roboguice 做了簡要的介紹,之后介紹了 Google Guice 的基本用法,Roboguice 是基本 Android 和 Google Guice 開發(fā)的適用于 Android 平臺的 Dependency Injection 開發(fā)包,下圖為使用 Roboguice 開發(fā)應(yīng)用的基本框圖:

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

Android 應(yīng)用程序可以直接使用 Google Guice 來為普通類進(jìn)行注入操作,而對和 Android 平臺相關(guān)的類如 Activity,Context,Service,View 等可以使用 Roboguice 進(jìn)行注入操作。

在例 Android RoboGuice 使用指南(2):第一個例子 Hello World 介紹了使用 RoboGuice 開發(fā)的步驟,原先從 Activity 派生的類一般需要改成從 RoboActivity 派生,并添加從 RoboApplication 派生的類作為 Application 應(yīng)用的 Application 類,詳細(xì)的對應(yīng)表如下:

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

RoboGuice 支持的標(biāo)記如下:

  • @ContextScoped : 表示 Scope 為 Context 范圍 Android RoboGuice 使用指南(11): Scopes
  • @InjectExtra : Intent 的 getExtra 的注入標(biāo)記
  • @InjectPreference: 注入 Preference
  • @InjectResource: 注入 Resource,如 drawable, icon 等
  • @InjectView: 注入 View
  • @Inject: Guice 標(biāo)記,可以注入 Android 平臺支持的各種服務(wù),比如 LocationManager 等。
  • @SharedPreferencesName: SharedPreferences 名稱等

此外,RoboGuice 還提供了簡單的消息 publish/subscribe 機(jī)制,以及可以支持 Dependency Injection 的 RoboThread, RoboAsyncTask ,RoboLooperThread 等,將在后面的文章詳細(xì)說明。