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注入是一种代码注入技术用于攻击数据驱动的应用程序在应用程序中,如果没有做恰当 ...
随机推荐
- 显示进度条tqdm
http://www.open-open.com/lib/view/open1451794925808.html
- UIScrollView 加载多个view view还可以交换顺序(1)
#import "ViewController.h" #define kWidthOfScreen self.view.frame.size.width #define kHeig ...
- dfs + 最小公倍数 Codeforces Round #383 (Div. 2)
http://codeforces.com/contest/742/problem/C 题目大意:从x出发,从x->f[x] - > f[f[x]] -> f[f[f[x]]] -& ...
- Java操作*.properties
java中的properties文件是一种配置文件,主要用于表达配置信息,文件类型为*.properties,格式为文本文件,文件的内容是格式是"键=值"的格式,在properti ...
- 让上下两个DIV块之间有一定距离或没有距离
1.若想上下DIV块之间距离,只需设定:在CSS里设置DIV标签各属性参数为0div{margin:0;border:0;padding:0;}这里就设置了DIV标签CSS属性相当于初始化了DIV标签 ...
- 还原openstack配置文件的方法
cp -a /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bakcp -a /etc/neutron/plugins/ml2/ml2_conf ...
- git容易被忽略的准备工作命令
安装git命令 $ apt-get install git-core 配置用户信息 $ git config --global user.name "wxw" $ git conf ...
- 字符串匹配之boyer-Moore算法
Boyer-Moore算法不仅效率高,而且构思巧妙,容易理解.1977年,德克萨斯大学的Robert S. Boyer教授和J Strother Moore教授发明了这种算法. 下面,我根据Moore ...
- SVN的学习以及使用!
什么是版本控制? 版本控制是记录一个或若干文件内容变化的系统.以便将来查阅特定版本修订情况. 版本控制,就像是一本历史书,记录了软件版本的迭代过程. 为什么需要"版本控制" 需要清 ...
- 忘记oracle用户名密码怎么办?
忘记oracle用户名密码怎么办? 忘记了安装时设置的用户名和密码怎么办?查了下网上的资料,终于解决了! 方法一: 首先进入sqlplus:进入的方式有两种,一种是通过cmd命令台输入sqlplus, ...