但是绑定
@BindView(R.id.phone_btn)
Button phoneBtn;
@BindView(R.id.alum_btn)
Button alumBtn;
@BindString(R.string.app_name)
String appName;
在ButterKnife.bind(this)之后得到appName和phoneBtn,alumBtn都为null
为什么会这样呢?
发现需要在Module的build.gradle里加上以下红色的内容
dependencies {
compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
compile ‘com.android.support:appcompat-v7:23.4.0‘
compile ‘com.jakewharton:butterknife:8.4.0‘
annotationProcessor ‘com.jakewharton:butterknife-compiler:8.4.0‘
compile ‘com.android.support:support-v4:23.4.0‘
}
本文探讨了ButterKnife在Android应用中绑定视图和字符串时遇到的问题,并给出了正确的依赖配置解决方案。
5729

被折叠的 条评论
为什么被折叠?



