• 特性:

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 forless than 50kb, without any runtimeperf impact!
@EActivity(R.layout.translate) // Sets content view to R.layout.translatepublic 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. 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
  2. 【Android(安卓)开发教程】TimePicker
  3. Android(安卓)GridView 方格中图标与文字如何同时存在
  4. Android(安卓)在子线程中更新UI
  5. android--使用NDK-build生成so
  6. Android中自定义适配器的使用
  7. Android(安卓)中View只能接收到ACTION_DOWN无法接收ACTION_MOVE
  8. android mediaplayer概况
  9. Android-Toast的使用方法详解

随机推荐

  1. Android各层推荐开发书籍及参考资料
  2. [android]android自动化测试七之动态AVD
  3. Android系统中TextView实现滚动效果
  4. Android版本和API Level
  5. android个人学习笔记——RatingBar
  6. Android TextView控件
  7. Android基础UI之ListView
  8. XE8 (RTM) Android SDK 更新安装
  9. Android(安卓)Notes 之 Tween动画 (3)添加
  10. Android学习笔记(二八):字体