Android Annotations是一个开源的框架,用于加速 Android应用的开发,可以让你把重点放在功能的实现上,简化了代码,提升了可维护性。

特性:

  • 依赖注入: inject views, extras, system services, resources, ...
  • 简化的线程模型: annotate your methods so that they execute on the UI thread or on a background thread.
  • Event 绑定: annotate methods to handle events on views, no more ugly anonymous listener classes!
  • REST 客户端: create a client interface, AndroidAnnotations generates the implementation.
  • AndroidAnnotations provide those good things and even more for less than 50kb, without any runtimeperf impact!
@EActivity(R.layout.translate) // Sets content view to R.layout.translate
public class TranslateActivity extends Activity { @ViewById // Injects R.id.textInput
EditText textInput; @ViewById(R.id.myTextView) // Injects R.id.myTextView
TextView result; @AnimationRes // Injects android.R.anim.fade_in
Animation fadeIn; @Click // When R.id.doTranslate button is clicked
void doTranslate() {
translateInBackground(textInput.getText().toString());
} @Background // Executed in a background thread
void translateInBackground(String textToTranslate) {
String translatedText = callGoogleTranslate(textToTranslate);
showResult(translatedText);
} @UiThread // Executed in the ui thread
void showResult(String translatedText) {
result.setText(translatedText);
result.startAnimation(fadeIn);
} // [...]
}

  

一些常用注释的使用方法:
@AfterInject 定义的方法在类的构造方法执行后执行
@AfterTextChange定义的方法在TextView及其子类的Text属性改变后执行
@AfterViews 定义的方法在setContentView后执行
@Background 定义的方法在后台线程执行
@BeforeTextChange 定义的方法在TextView及其子类的Text属性改变前执行
@Click 定义点击监听器
@EActivity 在Activity中启用Annotations
@EProvider 在 ContentProvider中启用Annotations
@EReceive 在BroadcastReceiver中启用Annotations
@EService 在Service中启用Annotations
@EView 在自定义的View的子类中启用Annotations
@Fullscreen 全屏
@NoTitle 无标题栏

掌握这些注视对读懂利用该第三方代码开发的代码非常有帮助,同时对利用该代码开发的APK文件反编译的解释能够有更深入的了解。

最新文章

  1. webconfig中配置各种数据库的连接字符串(转)
  2. Github的命令清除
  3. 关于UltraEdit的两个小问题
  4. jenkins 邮件配置
  5. iOS-UIView 之 layoutMargins & preservesSuperviewLayoutMargins 解惑
  6. 数独检测器:帝国理工C++作业
  7. 【BZOJ】2084: [Poi2010]Antisymmetry
  8. poj 2823 Sliding Window (单调队列入门)
  9. 《Java核心技术卷二》笔记(二)文件操作和内存映射文件
  10. java基础:数据类型
  11. Redis安装与基本配置(转)
  12. 对于querystring取值时候发生+号变空格的问题
  13. Windows恢复Grub引导,用grub安装ubuntu
  14. TortoiseSVN使用简介
  15. WP8.1程序开发中,如何加载本地文件资源或安装在程序包中的资源。
  16. 微信小程序之微信登陆 —— 微信小程序教程系列(20)
  17. JavaScript大师必须掌握的12个知识点
  18. Git——入门操作加创建账号【三】
  19. html/css/js-layer弹出层的初次使用
  20. Head First Servlets & JSP 学习笔记 第九章 —— 使用JSTL

热门文章

  1. Java单元测试之覆盖率统计eclemma
  2. Swing-布局管理器之FlowLayout(流式布局)-入门
  3. 201521123061 《Java程序设计》第九周学习总结
  4. Java补码表和位移运算符
  5. 201521123049 《JAVA程序设计》 第14周学习总结
  6. 201521123099 《Java程序设计》第13周学习总结
  7. select应用于read函数 超时非阻塞方式
  8. Spring第七篇【Spring的JDBC模块】
  9. 【二】刚学Python的几道简单练习题
  10. SpringMVC的数据格式化-注解驱动的属性格式化