为了码代码的效率,我们有了ButterKnife;其基本使用如下步骤:

1.在Android Studio的Setting中,下载plugin

2.在整个Project的build.gradle中添加butterknife依赖

buildscript {
repositories {
jcenter()
maven{ url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
//这里配置 apt 供butterknife使用
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
} allprojects {
repositories {
jcenter() maven { url "https://jitpack.io" }
}
} task clean(type: Delete) {
delete rootProject.buildDir
}

3.在你要使用的module的build.gradle中添加butterknife的依赖

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.lemon.livecircledemo"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12' compile 'com.android.support:design:25.1.0'
//视图绑定 butterknife
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'

compile 'de.greenrobot:eventbus:3.0.0-beta1'
//引入okhttp
compile 'com.squareup.okhttp3:okhttp:3.5.0'
//引入retrofit
compile 'com.squareup.retrofit2:retrofit:2.1.0'
//引入rxjava
compile 'io.reactivex.rxjava2:rxjava:2.0.4'
//引入Log拦截器,方便DEBUG模式输出log信息
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
//引入rxjava适配器,方便rxjava与retrofit的结合
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//引入json转换器,方便将返回的数据转换为json格式
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//引入rxandroid
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.github.Aspsine:IRecyclerView:0.0.5' }

4.在你的setContentView()中,选中布局,右键Generator,在代码中自动生成相关的视图绑定。

Android开发学习——ButterKnife使用的更多相关文章

  1. Android开发学习之路-RecyclerView滑动删除和拖动排序

    Android开发学习之路-RecyclerView使用初探 Android开发学习之路-RecyclerView的Item自定义动画及DefaultItemAnimator源码分析 Android开 ...

  2. Android开发学习路线图

    Android开发学习方法: Android是一个比较庞大的体系,从底层的Linux内核到上层的应用层,各部分的内容跨度也比较大.因此,一个好的学习方法对我们学习Android开发很重要. 在此建议, ...

  3. android开发学习笔记000

    使用书籍:<疯狂android讲义>——李刚著,2011年7月出版 虽然现在已2014,可我挑来跳去,还是以这本书开始我的android之旅吧. “疯狂源自梦想,技术成就辉煌.” 让我这个 ...

  4. Android开发学习总结(一)——搭建最新版本的Android开发环境

    Android开发学习总结(一)——搭建最新版本的Android开发环境(转) 最近由于工作中要负责开发一款Android的App,之前都是做JavaWeb的开发,Android开发虽然有所了解,但是 ...

  5. Android开发学习之LauncherActivity开发启动的列表

    Android开发学习之LauncherActivity开发启动的列表 创建项目:OtherActivity 项目运行结果:   建立主Activity:OtherActivity.java [jav ...

  6. 最实用的Android开发学习路线分享

    Android开发学习路线分享.Android发展主导移动互联发展进程,在热门行业来说,Android开发堪称火爆,但是,虽然Android有着自身种种优势,但对开发者的专业性要求也是极高,这种要求随 ...

  7. Android开发学习必备的java知识

    Android开发学习必备的java知识本讲内容:对象.标识符.关键字.变量.常量.字面值.基本数据类型.整数.浮点数.布尔型.字符型.赋值.注释 Java作为一门语言,必然有他的语法规则.学习编程语 ...

  8. Android开发学习之路--基于vitamio的视频播放器(二)

      终于把该忙的事情都忙得差不多了,接下来又可以开始good good study,day day up了.在Android开发学习之路–基于vitamio的视频播放器(一)中,主要讲了播放器的界面的 ...

  9. Android开发学习之路--Android Studio cmake编译ffmpeg

      最新的android studio2.2引入了cmake可以很好地实现ndk的编写.这里使用最新的方式,对于以前的android下的ndk编译什么的可以参考之前的文章:Android开发学习之路– ...

随机推荐

  1. mina客户端与服务端通信的易错点

    使用mina进行项目开发时,如果客户端与服务端不在同一个项目下,需要关注一下两点: 第一.服务端与客户端的编码解码器一致 第二.过程中所用到的实体类的包名需要一致

  2. 关于Python中正则表达式的反斜杠问题

    之前总是搞不明白正则表达式中的反斜杠的问题.今天经过查阅资料终于搞明白了. 其中最重要的一点就是Python自己的字符串中定义的反斜杠也是转义字符,而正则表达式中的反斜杠也是转义字符,所以正则表达式中 ...

  3. React Native入门——布局实践:开发京东client首页(一)

    有了一些对React Native开发的简单了解,让我们从实战出发.一起来构建一个简单的京东client. 这个client是仿照之前版本号的京东client开发的Android版应用,来源于CSDN ...

  4. java实用技能 上传文件 等等

    1.IOS  AES对称加密,加密结果不同,问题解决 IOS http post请求,使用AFNetworing 框架,默认请求content-type为application/json ,所以无法使 ...

  5. Cocos从入门到精通--《创建第一个项目:HelloWorld》

    上节课我们解说了cocos2-x v3.7版本号的下载安装,也展示了使用CocosStudio编译不同平台运行程序的方法,大家是不是对新版本号的Cocos引擎充满期待?今天我们就创建一个project ...

  6. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心

    E. Prairie Partition It can be shown that any positive integer x can be uniquely represented as x =  ...

  7. C#生成Excel文件后彻底解除占用代码(来着CSDN)

    http://bbs.csdn.net/topics/280078428 jy251 LS说KILL进程的朋友们···我说...你们真行!!!如果用户是administrator还行,如果不是怎么办? ...

  8. solr 命令

    本文为转载内容:源地址:http://blog.csdn.net/matthewei6/article/details/50620600 查看帮助 bin/solr -help            ...

  9. C# 取html <data>内容

    private void button1_Click(object sender, EventArgs e) { string strSource = GetHttpWebRequest(" ...

  10. POJ2528 Mayor's posters —— 线段树染色 + 离散化

    题目链接:https://vjudge.net/problem/POJ-2528 The citizens of Bytetown, AB, could not stand that the cand ...