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 ...
随机推荐
- 201521123069 《Java程序设计》 第2周学习总结
1. 本章学习总结 (1)String类.StringBuilder类(频繁进行字符串的修改应选用StringBuilder,不会生成大量的字符串对象).Math类的用法.字符串池的概念 (2)Sca ...
- 201521123042《Java程序设计》 第9周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. ①finally块:无论是否被捕获或执行异常一定会被执行. 在try或catch中遇到return语句时,final ...
- java课程设计---彩票销售管理系统
彩票购买销售系统 1.项目git地址 https://git.oschina.net/fenm/lotterry.git 部分项目地址提交截图 项目主要功能图 团队博客链接 http://www.cn ...
- 多线程面试题系列(3):原子操作 Interlocked系列函数
上一篇中讲到一个多线程报数功能.为了描述方便和代码简洁起见,我们可以只输出最后的报数结果来观察程序是否运行出错.这也非常类似于统计一个网站每天有多少用户登录,每个用户登录用一个线程模拟,线程运行时会将 ...
- csv文件读取
from urllib.request import urlopen from io import StringIO import csv data = urlopen("http://py ...
- 2.bootstrap-全局css
1.Bootstrap 网格系统 Bootstrap 提供了一套响应式.移动设备优先的流式网格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列. 1.基本的网格结构 下面是 ...
- leetCode in Java (一)
前言 感觉写博客是一个很耗心力的东西T_T,简单的写了似乎没什么用,复杂的三言两语也只能讲个大概,呸呸...怎么能有这些消极思想呢QAQ!那想来想去,先开一个leetcode的坑,虽然已经工作了 ...
- [VirtualBox] 1、NAT模式下端口映射
1.VirtualBox中有4中网络连接方式 VirtualBox中有4中网络连接方式:NAT.Bridged Adapter.Internal.Host-only Adapter,VMWare中有三 ...
- apollo实现c#与android消息推送(一)
之前做了c#推送消息到手机端,限于网络要求,不能使用百度等现成的推送,查了许多资料,七拼八凑终于凑齐,记录下来,即是复习也是希望对来者有所帮助. 我开发的环境是windows,使用java开发的Apa ...
- 基于maven创建和部署Webx项目
1.准备工作 下载 Webx Maven 项目的目录结构Artifact插件. archetype-webx-quickstart-1.0.tar.gz插件:http://central.maven. ...