`
lyunabc
  • 浏览: 530672 次
  • 性别: Icon_minigender_2
社区版块
存档分类
最新评论

Android RoboGuice 使用指南(18):Inject Resources

 
阅读更多

Roboguice 对访问res 目录下各种资源drawable, arrary, string 等也提供了注入支持。可以通过@InjectResource 很方便的应用所需资源。

本例修改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);
 
 }
 
}


本例下载

分享到:
评论

相关推荐

    Android代码-injectio

    Inject.io []() Tiny and nice injections syntax sugar for Android. If you're using heavy injection frameworks just to inject views and resources try this. Wat? Just few lines of code, completely no...

    安卓Android源码——Inject增加sqlite3数据库映射注解(ORM).zip

    安卓Android源码——Inject增加sqlite3数据库映射注解(ORM).zip

    InjectDLL_injectDll_

    Usage: injectdll.exe [process name] [dll path] [option number]option 1 - CreateRemoteThreadoption 2 - NtCreateThreadExoption 3 - RtlCreateUserThread

    inject:围绕javax.inject批注的简单Kotlin多平台抽象

    例如,在Kotlin公共代码中的构造函数上使用Inject注释: class MyUseCase @Inject constructor() { .. . } 可用的注释和界面 @Inject @Named("name") @Qualifier @Scope @Singleton Provider 建立图书馆 该库...

    InjectCSSToWebView:Inject CSS To WebView ; 将CSS注入WebView

    InjectCSSToWebView##Inject CSS To WebView ;##将CSS注入WebView .NO.1,Before load WebView,Inject CSS. 在加载WebView之前注入CSS。NO.2,After load WebView,Inject CSS. 在加载WebView之后注入CSS。

    sisu-inject-bean-1.4.2.jar

    sisu-inject-bean-1.4.2.jar

    vue 解决provide和inject响应的问题

    官网上说provide 和 inject 绑定并不是可响应的。这是刻意为之的。然而,如果你传入了一个可监听的对象,那么其对象的属性还是可响应的。 provide: Object | () => Object(一个对象或返回一个对象的函数) inject...

    rage_vnc.rar_KAZAA_Morpheus _inject_p2p vnc_rage_vnc

    Functions: Topic parsing, supporting multi-commands Anti-Botkiller Anti-Sandbox VNC-Scanner ...inject disconnect reconnect reconnect.next nick restart vncstop patch part join scan msn

    meteor-inject-data:一种使用初始HTML向客户端注入数据的方法

    安装meteor add communitypackages:inject-data推送数据我们需要将此包与服务器端路由器一起使用。 我们扩展了nodejs http.OutgoingMessage并提供了这样的API。 这是的示例。 Picker . route ( '/' , function ( ...

    巫术:注入JS和CSS。「Witchcraft: Inject JS and CSS」-crx插件

    从您的家庭文件夹注入Javascript和...*可在Windows,Mac和Linux上使用; *同时处理JS和CSS; * @include指令可从域脚本内部加载其他JS文件。 安装扩展程序后,请访问该网站以了解将脚本存储在何处。 支持语言:English

    mimikatzWIN服务器神器

    使用方法: 1. 运行主程序:mimikatz.exe 2. 输入:privilege::debug 提升权限 3. 输入:inject::process lsass.exe sekurlsa.dll 将sekurlsa.dll 注入到lsass.exe 中 4. 输入:@getLogonPasswords 即可获取hash...

    VC代码 RT_INJECT (实用代码源)

    VC代码 RT_INJECT (实用代码源)VC代码 RT_INJECT (实用代码源)VC代码 RT_INJECT (实用代码源)VC代码 RT_INJECT (实用代码源)VC代码 RT_INJECT (实用代码源)VC代码 RT_INJECT (实用代码源)VC代码 RT_INJECT (实用代码...

    Android使用注解查找控件

    Android 开发使用的inject注解查找控件实例

    Inject:黑帽子2017

    原理使用的是:windows NTFS机制。在实际应用中,我们想制定父进程,进行伪装。将NtCreateProcessEx函数的第四个参数,指向我们制定的进程的句柄。原文档引用:Inject-dll-by-Process-DoppelgangingProcess Doppelg...

    vue中的provide/inject的学习使用

    provider/inject:简单的来说就是在父组件中通过provider来提供变量,然后在子组件中通过inject来注入变量。 需要注意的是这里不论子组件有多深,只要调用了inject那么就可以注入provider中的数据。而不是局限于只能...

    Android注解框架AndroidInject.zip

    AndroidInject 是 Android 注解框架,以简化 Android 开发 目前完成的注解(持续增加中): @AINoTitle: 类注解, 只适用于Activity(需继承于AIActivity), 设置Activity不显示Title  @AIFullScreen: 类注解...

    methodinject,面向android卓aop框26550;的MethodInject.zip

    methodinject,面向android卓aop框26550;的MethodInject.zip

    javax.inject.jar

    javax.inject.jar java 开发技术要用到,打包分享给大家,需要的下载学习哈!

    FreeZ_MadCollection.v2.5.7.0_FS

    2005-04-29 18:01 8243 72 madExcept\Demos\EC.bdsproj 2004-10-03 11:00 8246 80 madCodeHook\Demos\system wide\VariousDlls\Empty.bdsproj 2004-10-03 10:36 8249 77 madExcept\Demos\ExcCatch.bdsproj 2004-10-...

    javax.inject.Provider

    Spring 依赖的 javax.inject.Provider

Global site tag (gtag.js) - Google Analytics