1、build.gradle 需要添加的内容
标注的颜色是新建项目之后,build.gradle文件需要添加的内容。
  1. buildscript {
  2. repositories {
  3. jcenter()
  4. }
  5. dependencies {
  6. classpath 'com.android.tools.build:gradle:1.1.1'
  7. classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
  8. }
  9. }
  10. apply plugin: 'com.android.application'
  11. apply plugin: 'android-apt'
  12. def AAVersion = '3.3.1'
  13. repositories {
  14. jcenter()
  15. }
  16. android {
  17. compileSdkVersion 21
  18. buildToolsVersion "21.1.2"
  19. defaultConfig {
  20. applicationId "com.lpc.test3.app"
  21. minSdkVersion 9
  22. targetSdkVersion 14
  23. versionCode 1
  24. versionName "1.0"
  25. }
  26. compileOptions {
  27. sourceCompatibility JavaVersion.VERSION_1_6
  28. targetCompatibility JavaVersion.VERSION_1_6
  29. }
  30. buildTypes {
  31. release {
  32. minifyEnabled false
  33. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  34. }
  35. }
  36. }
  37. dependencies {
  38. compile fileTree(dir: 'libs', include: ['*.jar'])
  39. compile 'com.android.support:appcompat-v7:22.1.1'
  40. }
  41. dependencies {
  42. apt "org.androidannotations:androidannotations:$AAVersion"
  43. compile "org.androidannotations:androidannotations-api:$AAVersion"
  44. }
  45. apt {
  46. arguments {
  47. androidManifestFile variant.outputs[0].processResources.manifestFile
  48. // if you have multiple outputs (when using splits), you may want to have other index than 0
  49. // If you're using flavors you should use the following line instead of hard-coded packageName
  50. // resourcePackageName android.defaultConfig.packageName
  51. // You can set optional annotation processing options here, like these commented options:
  52. // logLevel 'INFO'
  53. // logFile '/var/log/aa.log'
  54. }
  55. }
2、activity_main内容
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:layout_width="match_parent"
  3. android:layout_height="match_parent"
  4. >
  5. <Button
  6. android:id="@+id/btn1"
  7. android:text="发送通知"
  8. android:layout_width="match_parent"
  9. android:layout_height="wrap_content"/>
  10. <Button
  11. android:layout_marginTop="10dp"
  12. android:layout_below="@id/btn1"
  13. android:id="@+id/btn2"
  14. android:text="清除通知"
  15. android:layout_width="match_parent"
  16. android:layout_height="wrap_content"/>
  17. </RelativeLayout>
3、MainActivity 内容
  1. package com.lpc.test3.app;
  2. import android.support.v7.app.ActionBarActivity;
  3. import android.view.View;
  4. import android.widget.Button;
  5. import android.widget.Toast;
  6. import org.androidannotations.annotations.Click;
  7. import org.androidannotations.annotations.EActivity;
  8. import org.androidannotations.annotations.ViewById;
  9. @EActivity(R.layout.activity_main)
  10. public class MainActivity extends ActionBarActivity {
  11. @ViewById
  12. Button btn1;
  13. @ViewById
  14. Button btn2;
  15. @Click
  16. void btn1(View v){
  17. Toast.makeText(MainActivity.this,"大家好",Toast.LENGTH_LONG).show();
  18. }
  19. }

4、最后的运行结果


androidannotations 简单配置的更多相关文章

  1. 小丁带你走进git世界一-git简单配置

    小丁带你走进git世界一-git简单配置 1.github的简单配置 配置提交代码的信息,例如是谁提交的代码之类的. git config  –global user.name BattleHeaer ...

  2. 以实际的WebGIS例子探讨Nginx的简单配置

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 以实际项目中的一个例子来详细讲解Nginx中的一般配置,其中涉 ...

  3. CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置

    1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB,两条命令都可以 systemctl sta ...

  4. ssm简单配置

    MyBatis 是一个可以自定义SQL.存储过程和高级映射的持久层框架. MyBatis 摒除了大部分的JDBC代码.手工设置参数和结果集重获. MyBatis 只使用简单的XML 和注解来配置和映射 ...

  5. 安装MariaDB和简单配置

    1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB systemctl start maria ...

  6. BIND的进程一:DNS简单配置与的主从配置

    DNS的简单配置和DNS的主从配置   摘要:DNS(Domain-Name Server) ,DNS的服务起到的作用就是名称解析,在网络通讯来说计算机与计算机是通过IP地址相互通信的, 当是IP地址 ...

  7. 转-squid介绍及其简单配置

    本文原始出处:http://linuxme.blog.51cto.com/1850814/372960 1.Squid是什么? Squid中文权威指南:http://zyan.cc/book/squi ...

  8. Linux中vim的简单配置

    本文主要分享Linux中vim的简单配置 ★配置文件的位置     在目录/etc.下面,有个名为vimrc的文件,这就是系统中公共的vim配置文件,对所有用户都开放.而在每个用户的主目录下,都可以自 ...

  9. CCNA网络工程师学习进程(6)vlan相关协议的配置与路由器简单配置介绍

        前面已经介绍了大部分与vlan技术相关的交换机的协议的配置,更深层次的还有STP协议和以太网端口聚合技术,接着还会简单介绍一下路由器的基本应用.     (1)STP(Spanning-tre ...

随机推荐

  1. (转)CVPR 2016 Visual Tracking Paper Review

    CVPR 2016 Visual Tracking Paper Review  本文摘自:http://blog.csdn.net/ben_ben_niao/article/details/52072 ...

  2. Sea.js学习4——Sea.js的配置

    可以对 Sea.js 进行配置,让模块编写.开发调试更方便. seajs.config seajs.config(options) 用来进行配置的方法. seajs.config({ // 别名配置 ...

  3. POJ2411

    题目大意:一个宽w高为h的棋盘,现在要用1*2的多米诺骨牌不重叠地覆盖整个棋盘,问有多少种方案. h<11,w<11 分析:1.h*w若为奇数,则无解. 2.按行处理.处理第i行时,保证前 ...

  4. ruby中rsa加签解签方法

    # coding:utf-8require 'openssl'require 'base64'# rsa签名,文本内容和私钥路径def rsa_sign(data,private_key_path) ...

  5. jsp中的<jsp:setProperty>中的param属性

    比如: <jsp:setProperty name="lader" property="edge" param="num" /> ...

  6. CSS3图片缩放

    鼠标指上去,图片放大,鼠标离开图片恢复原样,并且有放大.缩小效果            Css代码实现:

  7. (转)无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。此操作失败的原因是对 IID 为“{00020970-

    HRESULT:0x80030002 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft ...

  8. 关于MOD

    同余式:正整数a,b对p取模,它们的余数相同,(a % p)=(b % p) 记做 或者a ≡ b (mod p). 运算规则 模运算与基本四则运算有些相似,但是除法例外.其规则如下:         ...

  9. .net一次连接执行多条sql语句

    方法一: string SQLString="select 1; select 2;"; using (OdbcConnection connection = new OdbcCo ...

  10. SQL中使用WITH AS提高性能,使用公用表表达式(CTE)简化嵌套SQL

    一.WITH AS的含义     WITH AS短语,也叫做子查询部分(subquery factoring),可以让你做很多事情,定义一个SQL片断,该SQL片断会被整个SQL语句所用到.有的时候, ...