butterknife的使用
第一步
在build.gradle添加依赖
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
在build.gradle的android里面添加配置
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
如图
第二步
绑定控件
@BindView(R.id.tv)
TextView tv;
在onCreate中
ButterKnife.bind(this);
如图
绑定监听事件
@OnClick(R.id.tv)
@OnLongClick(R.id.tv)
如图