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. Android学习七:new Date使用

    1.例子 学习时间函数,并实现了简单的多个按钮监听同一个事件的方法 2.代码 代码很简单,也很清晰 package com.example.datetime; import java.text.Sim ...

  2. 033. asp.netWeb用户控件之二将页面转换成web控件和使用Web控件显示热点新闻

    访问Web用户控件的属性 ASP.NET提供的各种服务器控件都有其自身的属性和方法,程序开发人员可以灵活地使用服务器控件中的属性和方法开发程序.在用户控件中,程序开发人员也可以自行定义各种属性和方法, ...

  3. docker swarm compose

    swarm docker run swarm --help compose curl -L https://github.com/docker/compose/releases/download/1. ...

  4. SQLServer2012中用于记录数据操作时刻的附加字段使用datetime2(3)就可以了

    datetime2(3)精确到毫秒(听说),约等于2005时代的datetime类型.实际上后者是精确到3.33毫秒(也是听说). ) = GETDATE(); ) = GETDATE(); ) = ...

  5. 【python】删除1~100的素数

    def delPrime(x): if x==1: return True for y in range(2,x): if x%y==0: return True return False x1=ra ...

  6. S7-1200 与 S7-200 的对比PPT

  7. jQuery入门级part.2

    一,事件编程 基本事件: blur(fn)     当失去焦点时 change(fn)  当内容发生改变时 click(fn)    当鼠标单击时 dblclick(fn)  当鼠标双击时 focus ...

  8. Bootstrap for MVC:Html.Bootstrap().TextBoxFor(model=>model.Name)

    在上篇博文中提到最近比较忙,也打过招呼Orchard系列文章更新速度可能会放缓,但还是会继续写下去,主要原因在最近想着开发一个新的东西(系统?组件?),等有一定成果时会跟大家分享一些相关的东西,今天介 ...

  9. 整合Apache+PHP教程

    首先修改Apache的配置文件,让Apache支持解析PHP文件,Apache配置文件在Apache安装目录的conf目录下的httpd.conf,打开此文件, 找到#LoadModule,在这个下面 ...

  10. APP测试点总结

    1.功能性测试: ——根据产品需求文档编写测试用例. ——软件设计文档编写用例. 注意:就是根据产品需求文档编写测试用例而进行测试.2.兼容性测试: ——android版本的兼容性 ——手机分辨率兼容 ...