Robuguide的使用

准备工作:

首先在项目中必须实现GreetingModule和RoboguiceDemoApplication

GreetingModule.java

import com.google.inject.AbstractModule;

public class GreetingModule extends AbstractModule {

@Override

protected void configure() {

}

}

RoboguiceDemoApplication.java

import roboguice.application.RoboApplication;

public class RoboguiceDemoApplication extends RoboApplication{

}

在values文件夹下必须出现如下文件:

Roboguice.xml文件中item对应工程中对应的GreetingModule

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string-array name="roboguice_modules">

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

</string-array>

</resources>

视图注入:

Activity必须继承实现RoboActivity

Demo如下:

public class InjectViewDemo extends RoboActivity {

@InjectView (R.id.button) Button goButton;

    @InjectView (R.id.textview1) TextView textView1;

    @InjectView (R.id.textview2) TextView textView2;

    @InjectView (R.id.textview3) TextView textView3;

    @InjectView (R.id.textview4) TextView textView4;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.injectview);

goButton.setOnClickListener(mGoListener);

}

private OnClickListener mGoListener = new OnClickListener()

{

public void onClick(View v)

{

textView1.setText("Clicked");

textView2.setText("Clicked");

textView3.setText("Clicked");

textView4.setText("Clicked");

}

};

}

视图界面:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:id="@+id/textview1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/injectview"

/>

<TextView

android:id="@+id/textview2"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/injectview"

/>

<TextView

android:id="@+id/textview3"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/injectview"

/>

<TextView

android:id="@+id/textview4"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/injectview"

/>

<Button android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_vertical"

android:text="@string/clickmebutton"/>

</LinearLayout>

Roboguice学习之视图注入的更多相关文章

  1. ASP.NET MVC学习之视图篇(2)

    继ASP.NET MVC学习之视图(1)学习 4.HTML辅助器 虽然在ASP.NET MVC中我们已经摆脱了ASP.NET的控件,但是对于页面中需要循环标签的情况依然还是存在,可能很多人认为用for ...

  2. Spring 学习笔记 ----依赖注入

    依赖注入 有三种方式,本文只学习下属性注入. 属性注入       属性注入即通过 setXxx方法()注入Bean的属性值或依赖对象,由于属性注入方式具有可选择性和灵活性高的优点,因此属性注入方式是 ...

  3. Butter Knife:一个安卓视图注入框架

    Butter Knife:一个安卓视图注入框架 2014年5月8日 星期四 14:52 官网: http://jakewharton.github.io/butterknife/ GitHub地址: ...

  4. python之MySQL学习——防止SQL注入

    python之MySQL学习——防止SQL注入 学习了:https://www.cnblogs.com/xiaomingzaixian/p/7126840.html https://www.cnblo ...

  5. ADO学习笔记之注入漏洞与参数化查询

    ADO学习笔记之注入漏洞与参数化查询 作为新手,在学习ADO程序时,使用 sql 语言查询数据时,很容易写类似如下代码: using (SqlConnection con = new SqlConne ...

  6. DVWA学习之SQL注入

    DVWA学习之SQL注入 环境工具 dvwa 1.9 phpstudy firefox burpsuite 实验步骤 一.设置安全级别为LOW 1. 登录DVWA,并将安全级别设置为LOW 2. 进入 ...

  7. MySQL学习——操作视图

    MySQL学习——操作视图 摘要:本文主要学习了使用DDL语句操作视图的方法. 了解视图 是什么 视图是从一个.多个表或者视图中导出的表,包含一系列带有名称的数据列和若干条数据行. 特点 视图不是数据 ...

  8. Web安全学习笔记 SQL注入下

    Web安全学习笔记 SQL注入下 繁枝插云欣 --ICML8 SQL注入小技巧 CheatSheet 预编译 参考文章 一点心得 一.SQL注入小技巧 1. 宽字节注入 一般程序员用gbk编码做开发的 ...

  9. Web安全学习笔记 SQL注入上

    Web安全学习笔记 SQL注入上 繁枝插云欣 --ICML8 SQL注入分类 SQL注入检测 一.注入分类 1.简介 SQL注入是一种代码注入技术用于攻击数据驱动的应用程序在应用程序中,如果没有做恰当 ...

随机推荐

  1. SharePoint 2013 图文开发系列之列表定义高级篇

    转载自  http://www.cnblogs.com/jianyus/p/3484714.html SharePoint列表库,是我们使用过程中最常用的库,下面,我们简单介绍下代码定义自定义列表,主 ...

  2. ADO.NET 数据访问类查询、属性扩展

    今天,我首先在之前所做的人员管理系统的基础上,利用数据访问类进行了所有人员信息的查询. 主程序代码: List<Users> Ulist = new UsersData().Select( ...

  3. UIAlertAction 弹出对话框9.0后有点变化

    ios 9.0后再用以前的UIAlertAction 已经不行了 被弃用了 改用这种方法了 UIAlertController *alertController = [UIAlertControlle ...

  4. xp添加右键"打开文件所在位置"

    以下代码保存为czmb.vbs文件并放在C:\windwos目录下: Set OS = GetObject("winmgmts:\\.\root\cimv2")Set CF = O ...

  5. 2016 百度之星初赛 Gym Class(优先队列+拓扑排序)

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Pract ...

  6. htaccess 实现网址缩短

    访问 :app.xxx.com/a 解析到:app.xxx.com/index.php/app/a <IfModule mod_rewrite.c> RewriteEngine on Re ...

  7. 避免IE执行AJAX时,返回JSON出现下载文件

    <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.conv ...

  8. style控制打印分页

    [转载地址:http://www.cnblogs.com/JustinYoung/articles/710734.html]page-break-before和page-break-after CSS ...

  9. VS2005--设置Release模式下调试

    今天初略看了下,所谓Release和Debug只是大家和编译器约定的一些生成规则而已,所以调试是无所谓Release和Debug的,只是由于生成的规则不同,可能Release的一些调试结果没Debug ...

  10. SQL 查询时间段内的时间

    declare @dt1 as datetime declare @dt2 as datetime set @dt1 = '2008-01-01' set @dt2 = '2009-01-01' ;w ...