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

鍍金池/ 教程/ Android/ Inject Resources
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

Inject Resources

Roboguice 對訪問 res 目錄下各種資源 drawable, arrary, string 等也提供了注入支持??梢酝ㄟ^ @InjectResource 很方便的應(yīng)用所需資源。

本例修改 Android ApiDemos 示例解析(48):Content->Resources->Resources 使用 Inject Resource 方法來訪問資源。

public class InjectResourceDemo extends RoboActivity {

 @InjectView (R.id.styled_text) TextView styled_text;
 @InjectView (R.id.plain_text) TextView plain_text;
 @InjectView (R.id.res1) TextView res1;
 @Inject Resources res;
 @InjectResource(R.string.styled_text) String str;

 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.injectresource);

 //Use res to get the string resources
 CharSequence cs=res.getText(R.string.styled_text);
 // Note the use of
 // CharSequence instead of String
 // so we don't lose the style info.
 styled_text.setText(cs);

 // Use the same resource, but convert it to
 // a string, which causes it
 // to lose the style information.
 plain_text.setText(str);
 res1.setText(cs);

 }

}

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

上一篇:概述下一篇:Inject View