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 ...
随机推荐
- hdu 5875(单调栈)
Function Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- 洛谷 P2788数学1(math1)- 加减算式 题解
题目传送门 这道题目可以使用C++的神奇功能: #include<bits/stdc++.h> using namespace std; int ans,t; int main(){ wh ...
- 783. Minimum Distance Between BST Nodes
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the ...
- css弹性盒子
body元素设置: <body> <div id="wai"> <div class="zi">1</div> ...
- 【PAT】1003. 我要通过!(20)
1003. 我要通过!(20) “答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”. ...
- python存取数据进阶技巧-pickle,array模块
我们在存/取数据时,没有必要存成文本形式,多试试二进制形式,文本只是骗骗眼睛的,要更快和更高效 1.数组形式 如果我们需要一个之包含数字的列表,那就试试array.array,注意,不是numpy模块 ...
- 在分享到微信里的网页中,打开qq对话框。
废话不多说,就是要去这个网址把qq申请一下服务. 网址: http://shang.qq.com/v3/widget.html 大概长这样: 2.截取这一段代码: 3.重新分享到微信,因为微信好像有缓 ...
- 用strtok函数分割字符串
用strtok函数分割字符串 需要在loadrunner里面获得“15”(下面红色高亮的部分),并做成关联参数. //Body response 内容: <BODY><; PRE&g ...
- Error:Unable to make the module:***, related gradle configuration was not found. Please, re-import the Gradle project and try again.
打开idea的 View -> Tool Windows -> Gradle.然后点击 Refresh
- Oracle表空间不足ORA-01654
v在往数据表里插入数据时,出现了ORA-01654: 索引 SSERVICE.IX_MSI_WDR_INPUT_1 无法通过 1024 (在表空间 USERD 中) 扩展的错误信息,原来是数据量太大, ...