android annotation配置及简单使用
2016-08-17 22:52
381 查看
1.环境配置
将 android annotations-api-3.1.jar拷贝到libs目录下
在项目的根目录中创建compile-libs 并放置 androidannotations-3.1.jar
2.右键单击项目->properties->
3.勾选Enable annotation processing
4.添加 jar文件
另外在一些Eclipse 中可能找不到Annotation Processing 这个选项。
这个需要安装一下插件。安装插件的步骤为:
1.单击Eclipse 中的Help->Install New Sorftware
Juno - http://download.eclipse.org/releases/juno
注意,标红的地方不要勾选,否则速度为很慢的。
整个项目的配置工作已经完成了,现在直接进入开发。
几个常用的标签
1.@EActivity
对布局文件进行注解,类似于setContentView(R.layout.activity_log);
2.@ViewById
@ViewById(R.id.user_password)
public EditText user_password;
可以在后面不跟着对应的Id,但是布局文件中的id必须和创建控件对应的名称必须一致。
@ViewById
public EditText user_name;
对多个控件进行@ViewById
@ViewById
TextView tv2,tv3;
3.@Click
设置单个Button的点击事件
@Click(R.id.login)
public void login(){
};
设置多个Button的点击事件。
4.@Background
在子线程中运行的方法,在方法上添加注解,方法会在子线程中运行。
public void dobackground(){
Log.i(TAG, “当前运行的线程”+Thread.currentThread().getId());
}
5.@UiThread
在UI线程中运行的方法
6.@StringRes
@StringRes
String str1;
7.@Extra
@Extra(“user_name”)
String name;
@AfterViews
初始化View之后执行的方法。
将 android annotations-api-3.1.jar拷贝到libs目录下
在项目的根目录中创建compile-libs 并放置 androidannotations-3.1.jar
2.右键单击项目->properties->
3.勾选Enable annotation processing
4.添加 jar文件
另外在一些Eclipse 中可能找不到Annotation Processing 这个选项。
这个需要安装一下插件。安装插件的步骤为:
1.单击Eclipse 中的Help->Install New Sorftware
Juno - http://download.eclipse.org/releases/juno
注意,标红的地方不要勾选,否则速度为很慢的。
整个项目的配置工作已经完成了,现在直接进入开发。
几个常用的标签
1.@EActivity
对布局文件进行注解,类似于setContentView(R.layout.activity_log);
2.@ViewById
@ViewById(R.id.user_password)
public EditText user_password;
可以在后面不跟着对应的Id,但是布局文件中的id必须和创建控件对应的名称必须一致。
@ViewById
public EditText user_name;
对多个控件进行@ViewById
@ViewById
TextView tv2,tv3;
3.@Click
设置单个Button的点击事件
@Click(R.id.login)
public void login(){
};
设置多个Button的点击事件。
4.@Background
在子线程中运行的方法,在方法上添加注解,方法会在子线程中运行。
public void dobackground(){
Log.i(TAG, “当前运行的线程”+Thread.currentThread().getId());
}
5.@UiThread
在UI线程中运行的方法
6.@StringRes
@StringRes
String str1;
7.@Extra
@Extra(“user_name”)
String name;
@AfterViews
初始化View之后执行的方法。
相关文章推荐
- spring 使用annotation替代xml配置实例(spring实现mail简单实现)
- AndroidAnnotation配置与使用
- Android SlidingMenu 简单配置和使用
- Android Annotation的一些简单使用
- (转)Android之高德地图SDK配置及简单使用详解
- Android 学习笔记-eclipse下ButterKnife配置和简单使用
- Android NDK——配置NDK及使用Android studio开发Hello JNI并简单打包so库
- Android-----第三方 ImageLoader 的简单配置和使用
- 解决使用Androidandroidannotations 配置时 Eclipse 不出现 Annotation Processor Factory
- 第二章:Android之NDK配置与简单使用
- androidannotations的简单配置和使用
- AndroidStudio中使用AndroidAnnotation的简单介绍
- Android上ORMLite的配置和简单使用
- Android之高德地图SDK配置及简单使用详解
- Android greenDao的简单配置和使用
- android 使用Eclipse开发NDK的配置和简单使用
- Android中Tomcat的简单配置和使用
- Android---ORMLite的配置和简单使用
- Android中简单配置读写,SharedPreferences的使用
- Android GreenDao 3.1简单配置与使用