Android开发之注解框架的使用(android annotations)
来源:互联网 发布:电子书管理类软件 编辑:程序博客网 时间:2024/05/21 10:39
我们首先讲讲使用注解开发有什么好处呢?
1.减少代码量,无需重复写类似代码
2.无需写handler+Thread处理超时操作
3.使代码简洁,规范,看起来方便
常用的注解:
@EActivity(R.layout.main)
引入布局layout
@ViewById(R.id.myInput)
EditText myInput;
找到相应的控件Id
@Click({R.id.button1,R.id.button2,R.id.button3})
doClickThing(){
}
对对应的控件设置点击事件
@AfterView
void init(){
}
加载界面完成后做的操作
@UiThread
处理耗时操作
@UiTread(delay=2)
handler 延迟操作
app的build.grade文件内容
<span style="font-size:18px;">buildscript { repositories { mavenCentral() } dependencies { // replace with the current version of the Android plugin classpath 'com.android.tools.build:gradle:1.2.3' // the latest version of the android-apt plugin classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' }}apply plugin: 'com.android.application'apply plugin: 'com.neenbedankt.android-apt'android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "你的包名" minSdkVersion 16 targetSdkVersion 21 versionCode 15 versionName "0.1.5" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } repositories { flatDir { dirs 'libs' } }}dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:support-v4:21.0.3' apt 'org.androidannotations:androidannotations:3.2' compile 'org.androidannotations:androidannotations-api:3.2'}apt { arguments { androidManifestFile variant.outputs[0].processResources.manifestFile resourcePackageName android.defaultConfig.applicationId }}</span>
0 0
- Android开发之注解框架的使用(android annotations)
- Android Annotations框架的使用
- Android开发之Android Annotations框架
- Android主流IOC框架浅析(注解反射,Annotations,ButterKnife的简单使用)
- Android注解使用之使用Support Annotations注解优化代码
- Android注解使用之使用Support Annotations注解优化代码
- Android中注解(Support Annotations)的使用
- 使用Android Annotations开发
- Intellij IDEA配置Android Annotations注解框架
- Intellij IDEA配置Android Annotations注解框架
- android studio 导入 annotations 注解框架
- Android第三方注解框架Annotations详解
- Android开发框架及注解的使用
- Android中注解(Support Annotations)的使用(二)自定义注解
- Android应用开发框架:Android Annotations
- Android Annotations 注解标签
- 【注解】android.support.annotations
- android studio 框架搭建:加入注解框架Annotations
- shell date命令
- mysql 【mysql的设计与优化专题】表的垂直拆分和水平拆分
- 杭电-1863 畅通工程(并查集+Kruscal)
- java项目之DRP完结
- **[RegexKitLite MRC 第三方框架的导入!]**
- Android开发之注解框架的使用(android annotations)
- css3新特性--弹性布局
- [AP]无线AP和无线路由的区别
- LightOJ1078 Integer Divisibility(同余定理)
- linux shell自定义函数(定义、返回值、变量作用域)介绍
- 整除-- 同余定理
- 【杭电oj1702】ACboy needs your help again!
- HDOJ 5777 domino
- 前端开发之初始化文档的CSS样式