Andorid之Annotation框架初使用(六)
EVENT
@Click :点击事件,只能有0个或1个参数,且参数为View
@Click(R.id.myButton)
void myButtonWasClicked() {
[...]
}
@Click
void anotherButton() {
[...]
}
@Click
void yetAnotherButton(View clickedView) {
[...]
}
@LongClick
@Touch
AdapterViewEvents
@ItemClick 必须有一个参数,如果这个参数是object类型,意味着adapter.getItem(position) ; 如果是int ,意味着是position
@LongItemClick 必须有一个参数,如果这个参数是object类型,意味着adapter.getItem(position) ; 如果是int ,意味着是position
@ItemSelect 必须有一个或者两个参数,第一个参数必须是boolean 第二个参数为adapter.getItem(position) 或者也可以是int ,意味着是position
@EActivity(R.layout.my_list)
public class MyListActivity extends Activity {
// ...
@ItemClick
public void myListItemClicked(MyItem clickedItem) { }
@ItemLongClick
public void myListItemLongClicked(MyItem clickedItem) {
}
@ItemSelect
public void myListItemSelected(boolean selected, MyItem selectedItem) {
}
}
或者:
@EActivity(R.layout.my_list)
public class MyListActivity extends Activity {
// ...
@ItemClick
public void myListItemClicked(int position) {
}
@ItemLongClick
public void myListItemLongClicked(int position) {
}
@ItemSelect
public void myListItemSelected(boolean selected, int position) {
}
}
SeekBarEvents:
@OnSeekBarProgressChange
@SeekBarProgressChange(R.id.seekBar)
void onProgressChangeOnSeekBar(SeekBar seekBar, int progress, boolean fromUser) {
// Something Here
} @SeekBarProgressChange(R.id.seekBar)
void onProgressChangeOnSeekBar(SeekBar seekBar, int progress) {
// Something Here
} @SeekBarProgressChange({R.id.seekBar1, R.id.seekBar2})
void onProgressChangeOnSeekBar(SeekBar seekBar) {
// Something Here
} @SeekBarProgressChange({R.id.seekBar1, R.id.seekBar2})
void onProgressChangeOnSeekBar() {
// Something Here
}
@SeekBarTouchStart
@SeekBarTouchStop
以上两个标签的方法有0个或一个参数 , 一个参数类型为 SeekBar
@FocusChange
@FocusChange(R.id.helloTextView)
void focusChangedOnHelloTextView(View hello, boolean hasFocus) {
// Something Here
} @FocusChange
void helloTextViewFocusChanged(View hello) {
// Something Here
} @FocusChange({R.id.editText, R.id.helloTextView})
void focusChangedOnSomeTextViews(View hello, boolean hasFocus) {
// Something Here
} @FocusChange(R.id.helloTextView)
void focusChangedOnHelloTextView() {
// Something Here
}
@CheckedChange
@CheckedChange(R.id.helloCheckBox)
void checkedChangeOnHelloCheckBox(CompoundButton hello, boolean isChecked) {
// Something Here
} @CheckedChange
void helloCheckBoxCheckedChanged(CompoundButton hello) {
// Something Here
} @CheckedChange({R.id.aCheckBox, R.id.helloCheckBox})
void checkedChangedOnSomeCheckBoxs(CompoundButton hello, boolean isChecked) {
// Something Here
} @CheckedChange(R.id.helloCheckBox)
void checkedChangedOnHelloCheckBox() {
// Something Here
}
@TextChange
@TextChange(R.id.helloTextView)
void onTextChangesOnHelloTextView(CharSequence text, TextView hello, int before, int start, int count) {
// Something Here
} @TextChange
void helloTextViewTextChanged(TextView hello) {
// Something Here
} @TextChange({R.id.editText, R.id.helloTextView})
void onTextChangesOnSomeTextViews(TextView tv, CharSequence text) {
// Something Here
} @TextChange(R.id.helloTextView)
void onTextChangesOnHelloTextView() {
// Something Here
}
@BeforeTextChange
@BeforeTextChange(R.id.helloTextView)
void beforeTextChangedOnHelloTextView(TextView hello, CharSequence text, int start, int count, int after) {
// Something Here
} @BeforeTextChange
void helloTextViewBeforeTextChanged(TextView hello) {
// Something Here
} @BeforeTextChange({R.id.editText, R.id.helloTextView})
void beforeTextChangedOnSomeTextViews(TextView tv, CharSequence text) {
// Something Here
} @BeforeTextChange(R.id.helloTextView)
void beforeTextChangedOnHelloTextView() {
// Something Here
}
@AfterTextChange
@AfterTextChange(R.id.helloTextView)
void afterTextChangedOnHelloTextView(Editable text, TextView hello) {
// Something Here
} @AfterTextChange
void helloTextViewAfterTextChanged(TextView hello) {
// Something Here
} @AfterTextChange({R.id.editText, R.id.helloTextView})
void afterTextChangedOnSomeTextViews(TextView tv, Editable text) {
// Something Here
} @AfterTextChange(R.id.helloTextView)
void afterTextChangedOnHelloTextView() {
// Something Here
}
Option Menu:
@EActivity
@OptionsMenu(R.menu.my_menu)
public class MyActivity extends Activity {
@OptionMenuItem
MenuItem menuSearch;
@OptionsItem(R.id.menuShare)
void myMethod() {
// You can specify the ID in the annotation, or use the naming convention
}
@OptionsItem
void homeSelected() {
// home was selected in the action bar
// The "Selected" keyword is optional
}
@OptionsItem
boolean menuSearch() {
menuSearch.setVisible(false);
// menuSearch was selected
// the return type may be void or boolean (false to allow normal menu processing to proceed, true to consume it here)
return true;
}
@OptionsItem({ R.id.menu_search, R.id.menu_delete })
void multipleMenuItems() {
// You can specify multiple menu item IDs in @OptionsItem
}
@OptionsItem
void menu_add(MenuItem item) {
// You can add a MenuItem parameter to access it
}
}
Andorid之Annotation框架初使用(六)的更多相关文章
- Andorid之Annotation框架初使用(七)
Save Instance State:程序保留Activity的实例状态 , 在onSaveInstanceState(Bundle)被系统调用的时候自动保存 , onCreate(Bundle)被 ...
- Andorid之Annotation框架初使用(五)
注入res文件夹的资源: @StringRes @EActivity public class MyActivity extends Activity { @StringRes(R.string.he ...
- Andorid之Annotation框架初使用(四)
代替繁琐的finViewById @EActivity public class MyActivity extends Activity { // Injects R.id.myEditText @V ...
- Andorid之Annotation框架初使用(三)
线程使用: @Background这个是使用了cached thread pool executor , 阻止开启过多的线程 可以为@Background指定一个id,用于随时终止线程的操作(Back ...
- Andorid之Annotation框架初使用(二)
Fragment: @EActivity(R.layout.fragments) public class MyFragmentActivity extends FragmentActivity { ...
- Andorid之Annotation框架初使用(一)
1. 设置Activity的布局 @EActivity(R.layout.main) public class MyActivity extends Activity {} 注: 此时在Android ...
- AVFoundation 框架初探究(二)
接着第一篇总结 系列第一篇地址:AVFoundation 框架初探究(一) 在第一篇的文章中,我们总结了主要有下面几个点的知识: 1.对AVFoundation框架整体的一个认识 2.AVSpeech ...
- 跟着刚哥学习Spring框架--JDBC(六)
Spring的JDBC框架 Spring JDBC提供了一套JDBC抽象框架,用于简化JDBC开发. Spring主要提供JDBC模板方式.关系数据库对象化方式.SimpleJdbc方式.事务管理来简 ...
- (转)MyBatis框架的学习(六)——MyBatis整合Spring
http://blog.csdn.net/yerenyuan_pku/article/details/71904315 本文将手把手教你如何使用MyBatis整合Spring,这儿,我本人使用的MyB ...
随机推荐
- c#元组举例
元组的概要: 数组合并了相同类型的对象,而元组合并了不同类型的对象.元组起源于函数编程语言(如F#) ,在 这些语言中频繁使用元组.在N盯4中,元组可通过.NET Fmmework用于所有的NET语言 ...
- 在go中连接mysql
5.访问数据库 5.1 database/sql接口 5.2 使用MySQL数据库 5.3 使用SQLite数据库 5.4 使用PostgreSQL数据库 5.5 使用Beego orm库进行ORM开 ...
- android Webview Html5 相关文章
Android WebView的使用集锦(支持Html5) http://blog.csdn.net/l_215851356/article/details/69239643 WebView详解与简单 ...
- Mybatis处理列名—字段名映射— 驼峰式命名映射
规范命名,数据库字段名使用 : 下划线命名(user_id) 类属性使用 : 驼峰命名(userId) 配置mybatis 时,全局设置: <settings> <!-- 开启驼峰, ...
- bzoj 1875 矩阵快速幂
思路:不能走走过来的路,变点交换跑矩阵快速幂. #include<bits/stdc++.h> #define LL long long #define fi first #define ...
- vs 单元测试
vs 2010 NOget 包 安装NUnitTDNet,下载TestDriven.NET(http://www.testdriven.net/). 准备动作 先到http://www.testdri ...
- EOJ 3263 丽娃河的狼人传说
差分约束系统,$spfa$. 首先判断无解,若某个约束的$t$大于区间长度,则一定无解. 否则一定有解,可以得到一系列的不等式: 最终区间和大于等于目前的区间和:$S[R]-S[L-1]≥val$, ...
- Docker应用系列(四)| 部署java应用
本示例基于Centos 7,假设目前使用的账号为release,拥有sudo权限. 由于Docker官方镜像下载较慢,可以开启阿里云的Docker镜像下载加速器,可参考此文进行配置. 主机上服务安装步 ...
- RabbitMQ (十六) 消息队列的应用场景 (转)
原贴 : http://blog.csdn.net/cws1214/article/details/52922267 消息队列中间件是分布式系统中重要的组件,主要解决应用耦合,异步消息,流量削锋等问题 ...
- python 进程间通信(下)
利用 Value,Array 先说明这个方法并不常用,因为有更灵活的方法 from multiprocessing import Process,Value,Array def f(n,a,not ...