气死我了,本来用ButterKnife这个插件是为了不用写FindViewById的代码
一直出错让我绝望
先说下ButterKnife的用法
- 在所使用的布局 ID 上点击右键 (例如 R.layout.activity_main ), 然后选择 Generate -> Generate ButterKnife Injections
- 在对话框中选择需要注入的 View, 还有个选项可以给 Adapter 创建一个 ViewHolder。
- 点击 Confirm , 代码自动生成!
不要自己去下 会出现一堆问题
project的build.gradle
//Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
// NOTE: Do not place your application dependencies here; they b