AS使用Android Annotation
来源:互联网 发布:怎么开农村淘宝店 编辑:程序博客网 时间:2024/05/08 15:11
如何在AS中使用最火的框架Android Annotation
目前Android有个很火的框架采用自动注解的方式加载view。我们大家都知道采用反射的方式是非常消耗性能的。但是Annotation官方则申明这种开源框架不但不会消耗性能,相反它还会很大程度上提高性能,大大的降低了维护的成本。提高开发效率是不用讲的了。现在就以这个为起步进行Android开发吧!
1.如何在AS中使用这种开源框架
自从从Eclipse转到AS开发后,就避不开的使用gradle这种构建方式。网上关于gradle的介绍是各种高大上。但是当我第一次使用时真是苦不堪言呀!真是会用了真是感觉他真是太方便了,不会用真是太痛苦了。本文不会介绍gradle的具体使用,如果需要请大家到网上搜索吧!下面就介绍如何在自己的项目中使用这种框架
- 首先要在全局build.gradle中进行配置需要添加如下的代码如下:
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
就是在dependencies节点中添加项目依赖,这样全局gradle就配置完成了。然后要在项目中gradle进行配置,就是项目最重要的gradle。
首先在开头添加如下的声明:
apply plugin: 'android-apt'def AAVersion = '3.3.2'
这是声明为apt,后面的版本号根据实际情况进行配置我这里是3.3.2
然后在这个配置文件的dependencies节点中加入如下的配置:
apt "org.androidannotations:androidannotations:$AAVersion" compile "org.androidannotations:androidannotations-api:$AAVersion"
- 最后重要的一点是千万不能忘记在最后配置apt节点这个很重要。配置如下:
`apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0// you should set your package name here if you are using different application IDs// resourcePackageName "your.package.name"// You can set optional annotation processing options here, like these commented options:// logLevel 'INFO'// logFile '/var/log/aa.log'
}
}`
这里就大功告成了,这样我们就能使用这个框架了。
- AS使用Android Annotation
- AS(Android studio)使用annotation
- Android annotation 使用注意事项
- Android Support Annotation Library 使用
- Android Annotation注解的剖析和使用
- Android中Annotation的使用详解
- android annotation配置及简单使用
- Android Annotation的一些简单使用
- Android进阶Support Annotation Library 使用详解
- Android注解使用之Annotation实现原理
- 【Android Studio】 AS 使用记录03(AS 常用插件)
- [Android Studio]使用AS开发Android
- android annotation
- Android -- Annotation
- Android Annotation
- as(android studio)的初次使用
- Android Studio 使用8-AS快捷键
- as(android studio)的初次使用
- 指针变量
- 项目中常遇见问题收录
- 什么是DOM以及DOM与javascript的简单区分
- list的拼接与去重
- SSH配置以及多个SSH & config文件
- AS使用Android Annotation
- 编写SNMP软件前的准备工作
- Android Studio常用插件
- ORA-00979: not a GROUP BY expression
- ViewPager动态加载布局
- php 总结
- 通过反射与注解拼装sql查询的小例子
- 天声人語 20151210 「あかつき」に女神ほほえむ
- 适配器模式