这是一个插件,方便自动进行findViewById 的操作。
1. 先安装 File - Settings - Plugins - 搜索 Android ButterKnife Zelezny,然后安装重启。如果不能安装成功,可以手动下载,手动从disk安装。
2. 在 module 的 build.gradle 添加:
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
3. 可以在layout的xml里边,右键 Generate Android Code 进行自动生成 butterknife 代码
4. 可以在Activity代码中,右键 R.layout.xxx,Generate... 可以选择 ButterKnife injections...