Roboguice学习之视图注入
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学习之视图注入的更多相关文章
- ASP.NET MVC学习之视图篇(2)
继ASP.NET MVC学习之视图(1)学习 4.HTML辅助器 虽然在ASP.NET MVC中我们已经摆脱了ASP.NET的控件,但是对于页面中需要循环标签的情况依然还是存在,可能很多人认为用for ...
- Spring 学习笔记 ----依赖注入
依赖注入 有三种方式,本文只学习下属性注入. 属性注入 属性注入即通过 setXxx方法()注入Bean的属性值或依赖对象,由于属性注入方式具有可选择性和灵活性高的优点,因此属性注入方式是 ...
- Butter Knife:一个安卓视图注入框架
Butter Knife:一个安卓视图注入框架 2014年5月8日 星期四 14:52 官网: http://jakewharton.github.io/butterknife/ GitHub地址: ...
- python之MySQL学习——防止SQL注入
python之MySQL学习——防止SQL注入 学习了:https://www.cnblogs.com/xiaomingzaixian/p/7126840.html https://www.cnblo ...
- ADO学习笔记之注入漏洞与参数化查询
ADO学习笔记之注入漏洞与参数化查询 作为新手,在学习ADO程序时,使用 sql 语言查询数据时,很容易写类似如下代码: using (SqlConnection con = new SqlConne ...
- DVWA学习之SQL注入
DVWA学习之SQL注入 环境工具 dvwa 1.9 phpstudy firefox burpsuite 实验步骤 一.设置安全级别为LOW 1. 登录DVWA,并将安全级别设置为LOW 2. 进入 ...
- MySQL学习——操作视图
MySQL学习——操作视图 摘要:本文主要学习了使用DDL语句操作视图的方法. 了解视图 是什么 视图是从一个.多个表或者视图中导出的表,包含一系列带有名称的数据列和若干条数据行. 特点 视图不是数据 ...
- Web安全学习笔记 SQL注入下
Web安全学习笔记 SQL注入下 繁枝插云欣 --ICML8 SQL注入小技巧 CheatSheet 预编译 参考文章 一点心得 一.SQL注入小技巧 1. 宽字节注入 一般程序员用gbk编码做开发的 ...
- Web安全学习笔记 SQL注入上
Web安全学习笔记 SQL注入上 繁枝插云欣 --ICML8 SQL注入分类 SQL注入检测 一.注入分类 1.简介 SQL注入是一种代码注入技术用于攻击数据驱动的应用程序在应用程序中,如果没有做恰当 ...
随机推荐
- visible绑定(The "visible" binding)
对visible进行绑定可以控制元素的显示和隐藏. 示例: <div data-bind="visible: shouldShowMessage"> You will ...
- ubuntu12.10下OpenFoam的编译
最近在ubuntu12.10下编译OpenFoam,遇到一些问题,小记一下. 首先到官网下载源码包(我这里下载的是OpenFOAM-2.3.0.tgz,ThirdParty-2.3.0.tgz). 1 ...
- svn hooks的使用demo
我是理论家: svn server端提供了Hooks Script.所谓钩子实际上是一种时间触发机制,是指当系统执行到某个特殊的事件时,触发我们预定义的动作,可以让我们在某些特定状态发生的时候做我们想 ...
- OC-之AFNetworking与ASIHTTPRequest对比
一.底层实现 1.AFN的底层实现基于OC的NSURLConnection和NSURLSession 2.ASI的底层实现基于纯C语言的CFNetwork框架 3.因为NSURLConnection和 ...
- iosUISegmentedControl的基本设置
//创建segmentControl 分段控件 UISegmentedControl *segC = [[UISegmentedControl alloc]initWithFrame:CGRectMa ...
- SMO 的环境
Microsoft SQL Server System CLR Types - http://go.microsoft.com/fwlink/?LinkId=123721&clcid=0x40 ...
- linux设置时间服务器
对多个linux服务器,时间保持一致是很必要的.根据精确度要求,应该有相应的时间间隔进行时间同步.如果不进行时间同步,时间久了就会差别很大,遇到问题时定位就很困难.因为多台设备的配合,log之间可能有 ...
- selenium C#下的zencart自动化测试(WFloginUrlPayment)环境4.0
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...
- Ubuntu 网管服务器配置
1.设置Linux内核支持ip数据包的转发 echo "1" > /proc/sys/net/ipv4/ip_forward or vi /etc/sysctl.conf ...
- Shell 流程控制-if for case while until break continue
Shell 流程控制 和Java.PHP等语言不一样,sh的流程控制不可为空,如(以下为PHP流程控制写法): <?php if (isset($_GET["q"])) { ...