Android Annotations(1)
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文件反编译的解释能够有更深入的了解。
Android Annotations(1)的更多相关文章
- 使用Android Annotations开发
使用Android Annotations框架gradle配置1.修改Module下的build.gradle apply plugin: 'com.android.application' appl ...
- Android Annotations Eclipse 配置 (3)
Android Annotations 本来我想写个 Java 版本的<RESTful客户端库:RestClient>用于 Android 应用开发,结果发现不太好写,虽然用了 Dynam ...
- Android Studio配置Android Annotations框架详解--说说那些坑
我们开发过程中都需要写些findViewByid.serOnclickListener等类似的代码,虽然不费事,但是一个项目下来,工作量还是很大的.为了节省工作量,运生了很多对应的注解框架.网上的博客 ...
- Android Annotations浅析
这阵子遇到了好多事情,挺久没来更新博文了,这两天在学这个开源框架Android Annotations,用起来感觉挺方便的, 相信用过Spring注解的孩子理解起来应该比較easy! 就是配置起来比較 ...
- Android Annotations 注解例子
1.AndroidAnnotations官网: http://androidannotations.org/ (也许你需要FQ) 2.eclipse中使用androidannotations的配置方法 ...
- Android annotations REST
使用前: public class BookmarksToClipboardActivity extends Activity { BookmarkAdapter adapter; ListView ...
- Android Annotations(2)
AndroidAnnotations是一个开源框架,旨在加快Android开发的效率.通过使用它开放出来的注解api,你几乎可以使用在任何地方, 大大的减少了无关痛痒的代码量,让开发者能够抽身其外,有 ...
- Android开发框架--AndroidAnnotations(一)
annotation:注解 什么是框架 框架是基石 android开发中哪些内容可以做成框架呢 网络模块 图片缓存模块 数据库模块 UI基础模块 开发框架给我们带来了哪些好处 提升开发效率 代码简洁 ...
- 转载自安卓巴士 【收藏】2015必须推荐的Android框架,猿必读系列!
一.Guava Google的基于java1.6的类库集合的扩展项目,包括collections, caching, primitives support, concurrency libraries ...
随机推荐
- 4th-结对编程2
0x00 Coding Coding地址/小伙伴的博客地址 合作伙伴:庞伊凡(201421123011).赵娅汀(201421123012) 0x01 题目描述 上一周大家为四则运算程序设计了2-3个 ...
- 201521123030 《Java程序设计》第8周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 1.2 选做:收集你认为有用的代码片段 2. 书面作业 本次作业题集集合 1.List中指定元素的删除(题目4 ...
- 《JAVA程序设计》第13周学习总结
1. 本章学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. GET / HTTP/1.0可以返回一个HTML格式的文本页 IP地址可以用来标识网络上的主机 Socke ...
- 201521123114 《Java程序设计》第14周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 1.数据库的定义:是为了实现一定目的按某种规则组织起来的"数据"的"集合" ...
- chrome保存网页为单个文件(mht格式)
网页归档(英语:MIME HTML或MIME Encapsulation of Aggregate HTML Documents,又称单一文件网页或网页封存盘案)为以多用途互联网邮件扩展格式,将一个多 ...
- select应用于read函数 超时非阻塞方式
/* * "Timed" read - timout specifies the # of seconds to wait before * giving up (5th argu ...
- mysql水平分表和垂直分表的优缺点
表分割有两种方式: 1.水平分割:根据一列或多列数据的值把数据行放到两个独立的表中. 水平分割通常在下面的情况下使用. •表很大,分割后可以降低在查询时需要读的数据和索引的页数,同时也降低了索引的层数 ...
- JVM菜鸟进阶高手之路六(JVM每隔一小时执行一次Full GC)
转载请注明原创出处,谢谢! 上次分析详细地址在:http://www.jianshu.com/p/a6236cd39e2d 以为上次问题是rmi的问题就此结束了,但是问题并没有结束,其实本次问题不是r ...
- 初学者一些常用的SQL语句(一)
一.数据库的创建create database 数据库名create database bbb二.表的创建 ***[]:可选项*** null:空值 not null 不为空***只有字符型能指定长度 ...
- [Node.js] 2、利用node-git-server快速搭建git服务器
本文用到了node-git-server 1.检测本地git版本 该包的使用需要机器上本来就安装git,且git的版本大于等于2.7: ╭─root@lt /home/workspace ╰─# gi ...