EVENT

@Click :点击事件,只能有0个或1个参数,且参数为View

  1. @Click(R.id.myButton)
  2. void myButtonWasClicked() {
  3. [...]
  4. }
  5. @Click
  6. void anotherButton() {
  7. [...]
  8. }
  9. @Click
  10. void yetAnotherButton(View clickedView) {
  11. [...]
  12. }

@LongClick

@Touch

AdapterViewEvents

@ItemClick 必须有一个参数,如果这个参数是object类型,意味着adapter.getItem(position) ; 如果是int ,意味着是position

@LongItemClick 必须有一个参数,如果这个参数是object类型,意味着adapter.getItem(position) ; 如果是int ,意味着是position

@ItemSelect 必须有一个或者两个参数,第一个参数必须是boolean 第二个参数为adapter.getItem(position) 或者也可以是int ,意味着是position

  1. @EActivity(R.layout.my_list)
  2. public class MyListActivity extends Activity {
  3. // ...
  4. @ItemClick
  5. public void myListItemClicked(MyItem clickedItem) {
  6.  
  7. }
  8. @ItemLongClick
  9. public void myListItemLongClicked(MyItem clickedItem) {
  10. }
  11. @ItemSelect
  12. public void myListItemSelected(boolean selected, MyItem selectedItem) {
  13. }
  14. }

或者:

  1. @EActivity(R.layout.my_list)
  2. public class MyListActivity extends Activity {
  3. // ...
  4. @ItemClick
  5. public void myListItemClicked(int position) {
  6. }
  7. @ItemLongClick
  8. public void myListItemLongClicked(int position) {
  9. }
  10. @ItemSelect
  11. public void myListItemSelected(boolean selected, int position) {
  12. }
  13. }

SeekBarEvents:

@OnSeekBarProgressChange

  1. @SeekBarProgressChange(R.id.seekBar)
  2. void onProgressChangeOnSeekBar(SeekBar seekBar, int progress, boolean fromUser) {
  3. // Something Here
  4. }
  5.  
  6. @SeekBarProgressChange(R.id.seekBar)
  7. void onProgressChangeOnSeekBar(SeekBar seekBar, int progress) {
  8. // Something Here
  9. }
  10.  
  11. @SeekBarProgressChange({R.id.seekBar1, R.id.seekBar2})
  12. void onProgressChangeOnSeekBar(SeekBar seekBar) {
  13. // Something Here
  14. }
  15.  
  16. @SeekBarProgressChange({R.id.seekBar1, R.id.seekBar2})
  17. void onProgressChangeOnSeekBar() {
  18. // Something Here
  19. }

@SeekBarTouchStart

@SeekBarTouchStop
以上两个标签的方法有0个或一个参数 , 一个参数类型为 SeekBar

@FocusChange

  1. @FocusChange(R.id.helloTextView)
  2. void focusChangedOnHelloTextView(View hello, boolean hasFocus) {
  3. // Something Here
  4. }
  5.  
  6. @FocusChange
  7. void helloTextViewFocusChanged(View hello) {
  8. // Something Here
  9. }
  10.  
  11. @FocusChange({R.id.editText, R.id.helloTextView})
  12. void focusChangedOnSomeTextViews(View hello, boolean hasFocus) {
  13. // Something Here
  14. }
  15.  
  16. @FocusChange(R.id.helloTextView)
  17. void focusChangedOnHelloTextView() {
  18. // Something Here
  19. }

@CheckedChange

  1. @CheckedChange(R.id.helloCheckBox)
  2. void checkedChangeOnHelloCheckBox(CompoundButton hello, boolean isChecked) {
  3. // Something Here
  4. }
  5.  
  6. @CheckedChange
  7. void helloCheckBoxCheckedChanged(CompoundButton hello) {
  8. // Something Here
  9. }
  10.  
  11. @CheckedChange({R.id.aCheckBox, R.id.helloCheckBox})
  12. void checkedChangedOnSomeCheckBoxs(CompoundButton hello, boolean isChecked) {
  13. // Something Here
  14. }
  15.  
  16. @CheckedChange(R.id.helloCheckBox)
  17. void checkedChangedOnHelloCheckBox() {
  18. // Something Here
  19. }

@TextChange

  1. @TextChange(R.id.helloTextView)
  2. void onTextChangesOnHelloTextView(CharSequence text, TextView hello, int before, int start, int count) {
  3. // Something Here
  4. }
  5.  
  6. @TextChange
  7. void helloTextViewTextChanged(TextView hello) {
  8. // Something Here
  9. }
  10.  
  11. @TextChange({R.id.editText, R.id.helloTextView})
  12. void onTextChangesOnSomeTextViews(TextView tv, CharSequence text) {
  13. // Something Here
  14. }
  15.  
  16. @TextChange(R.id.helloTextView)
  17. void onTextChangesOnHelloTextView() {
  18. // Something Here
  19. }

@BeforeTextChange

  1. @BeforeTextChange(R.id.helloTextView)
  2. void beforeTextChangedOnHelloTextView(TextView hello, CharSequence text, int start, int count, int after) {
  3. // Something Here
  4. }
  5.  
  6. @BeforeTextChange
  7. void helloTextViewBeforeTextChanged(TextView hello) {
  8. // Something Here
  9. }
  10.  
  11. @BeforeTextChange({R.id.editText, R.id.helloTextView})
  12. void beforeTextChangedOnSomeTextViews(TextView tv, CharSequence text) {
  13. // Something Here
  14. }
  15.  
  16. @BeforeTextChange(R.id.helloTextView)
  17. void beforeTextChangedOnHelloTextView() {
  18. // Something Here
  19. }

@AfterTextChange

  1. @AfterTextChange(R.id.helloTextView)
  2. void afterTextChangedOnHelloTextView(Editable text, TextView hello) {
  3. // Something Here
  4. }
  5.  
  6. @AfterTextChange
  7. void helloTextViewAfterTextChanged(TextView hello) {
  8. // Something Here
  9. }
  10.  
  11. @AfterTextChange({R.id.editText, R.id.helloTextView})
  12. void afterTextChangedOnSomeTextViews(TextView tv, Editable text) {
  13. // Something Here
  14. }
  15.  
  16. @AfterTextChange(R.id.helloTextView)
  17. void afterTextChangedOnHelloTextView() {
  18. // Something Here
  19. }

Option Menu:

  1. @EActivity
  2. @OptionsMenu(R.menu.my_menu)
  3. public class MyActivity extends Activity {
  4. @OptionMenuItem
  5. MenuItem menuSearch;
  6. @OptionsItem(R.id.menuShare)
  7. void myMethod() {
  8. // You can specify the ID in the annotation, or use the naming convention
  9. }
  10. @OptionsItem
  11. void homeSelected() {
  12. // home was selected in the action bar
  13. // The "Selected" keyword is optional
  14. }
  15. @OptionsItem
  16. boolean menuSearch() {
  17. menuSearch.setVisible(false);
  18. // menuSearch was selected
  19. // the return type may be void or boolean (false to allow normal menu processing to proceed, true to consume it here)
  20. return true;
  21. }
  22. @OptionsItem({ R.id.menu_search, R.id.menu_delete })
  23. void multipleMenuItems() {
  24. // You can specify multiple menu item IDs in @OptionsItem
  25. }
  26. @OptionsItem
  27. void menu_add(MenuItem item) {
  28. // You can add a MenuItem parameter to access it
  29. }
  30. }

Andorid之Annotation框架初使用(六)的更多相关文章

  1. Andorid之Annotation框架初使用(七)

    Save Instance State:程序保留Activity的实例状态 , 在onSaveInstanceState(Bundle)被系统调用的时候自动保存 , onCreate(Bundle)被 ...

  2. Andorid之Annotation框架初使用(五)

    注入res文件夹的资源: @StringRes @EActivity public class MyActivity extends Activity { @StringRes(R.string.he ...

  3. Andorid之Annotation框架初使用(四)

    代替繁琐的finViewById @EActivity public class MyActivity extends Activity { // Injects R.id.myEditText @V ...

  4. Andorid之Annotation框架初使用(三)

    线程使用: @Background这个是使用了cached thread pool executor , 阻止开启过多的线程 可以为@Background指定一个id,用于随时终止线程的操作(Back ...

  5. Andorid之Annotation框架初使用(二)

    Fragment: @EActivity(R.layout.fragments) public class MyFragmentActivity extends FragmentActivity { ...

  6. Andorid之Annotation框架初使用(一)

    1. 设置Activity的布局 @EActivity(R.layout.main) public class MyActivity extends Activity {} 注: 此时在Android ...

  7. AVFoundation 框架初探究(二)

    接着第一篇总结 系列第一篇地址:AVFoundation 框架初探究(一) 在第一篇的文章中,我们总结了主要有下面几个点的知识: 1.对AVFoundation框架整体的一个认识 2.AVSpeech ...

  8. 跟着刚哥学习Spring框架--JDBC(六)

    Spring的JDBC框架 Spring JDBC提供了一套JDBC抽象框架,用于简化JDBC开发. Spring主要提供JDBC模板方式.关系数据库对象化方式.SimpleJdbc方式.事务管理来简 ...

  9. (转)MyBatis框架的学习(六)——MyBatis整合Spring

    http://blog.csdn.net/yerenyuan_pku/article/details/71904315 本文将手把手教你如何使用MyBatis整合Spring,这儿,我本人使用的MyB ...

随机推荐

  1. poj 1077(BFS预处理+康托展开)

    Eight Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 29935   Accepted: 13029   Special ...

  2. 用JDK自带的监控工具jconsole来监控程序运行

    工具目录:C:\Program Files\Java\jdk1.6.0_06\bin\jconsole.exe 效果如下:监控类ThreadPoolExecutorTest 的运行 选择我们运行的程序 ...

  3. n*m的矩阵,行和列都递增有序,求是否出现target元素(面试题)

    题目描述:给定一个n*m的矩阵,矩阵的每一行都是递增的,每一列也是递增的,给定一个元素target,问该target是否在矩阵中出现. 思路:先从最左下角的元素开始找,三种情况: 1. 如果该元素大于 ...

  4. 原生js粘贴复制【源码】

    <html> <head> <meta charset="UTF-8"> <title>9行代码实现复制内容至剪切板</tit ...

  5. 【caffe-Windows】微软官方caffe之matlab接口配置,以及安装caffe的注意事项

    1.在此之前,记录一下之前的错误,在参考博客[caffe-Windows]caffe+VS2013+Windows+GPU配置+cifar使用进行caffe的安装时,其中的一些步骤可以不做,具体见下图 ...

  6. lr中用strtok函数分割字符串

    需要在loadrunner里面获得“15”(下面红色高亮的部分),并做成关联参数. ,6,5,0,4,0,3,0,3,2,0,0,0,1 用web_reg_save_param取出“8,7,5,15, ...

  7. run-time setting 中设置simulate browser cache 选项详解

    Browser  Emulation: Simulate  browser  cache:配置Vuser模拟带缓存的浏览器.缺省缓存是被允许的, 可以通过禁止该选项来使得所有VUser模拟的浏览器都不 ...

  8. php大图

    原文地址:https://laravel-china.org/articles/9450/php-fpm-vs-swoole

  9. vue表格导入

    <input id="upload" type="file" @change="importfxx(this)"  accept=&q ...

  10. FastReport.Net使用:[8]交叉表一

    1.绘制报表标题,交叉表可以直接放在标题栏内. 2.拖动一交叉表控件到标题栏内. 3.设置交叉表的行列信息. 将Tabel中的[科室名称]列拖到交叉表的列上以创建列,将Tabel中的[姓名]列拖到交叉 ...