使用導(dǎo)航
1. 導(dǎo)入包
compile 'com.jakewharton:butterknife:7.0.1'
2.在onCreat方法中 初始化
ButterKnife.bind(this); 或者 ButterKnife.bind(this,view);
報(bào)錯(cuò)導(dǎo)航
1.java.lang.RuntimeException: Unable to bind views for Fragment on ButterKnife.bind(this, view).?
報(bào)錯(cuò)原因: R.id.name, 1. 找不到當(dāng)前界面相對(duì)應(yīng)的此id
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2.有此id, 但是此id的類型與實(shí)際不符合, 比如? @Bind(R.id.img)Imageview? img; 但是布局中卻是ImageButton的類型
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?3.類似于toolbar的情況,可能是導(dǎo)包錯(cuò)誤,
2.androidstudio3.0使用butterknife報(bào)錯(cuò)解決
在build.gradle中添加配置
android {
? ? ?defaultConfig {
? ? ? ? ? ? ?javaCompileOptions {
? ? ? ? ? ? annotationProcessorOptions {
? ? ? ? ? ? ? ? includeCompileClasspath = true?
? ? ? ? ? ? }
? ? ? ? }
? ? }
}