为什么ButterKnife.bind之后View依然为null
答案:2 悬赏:30 手机版
解决时间 2021-02-07 06:35
- 提问者网友:抽煙菂渘情少年
- 2021-02-06 07:52
为什么ButterKnife.bind之后View依然为null
最佳答案
- 五星知识达人网友:逃夭
- 2021-02-06 08:14
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.administrator.demo"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/jsoup-1.9.2.jar')
compile files('libs/Volley.jar')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.jakewharton:butterknife:8.1.0'
compile 'com.android.support:design:23.4.0'
compile 'com.cjj.materialrefeshlayout:library:1.3.0'
compile 'com.android.support:support-v4:23.4.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}
这是我的 build.gradle 里的内容
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.administrator.demo"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/jsoup-1.9.2.jar')
compile files('libs/Volley.jar')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.jakewharton:butterknife:8.1.0'
compile 'com.android.support:design:23.4.0'
compile 'com.cjj.materialrefeshlayout:library:1.3.0'
compile 'com.android.support:support-v4:23.4.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}
这是我的 build.gradle 里的内容
全部回答
- 1楼网友:枭雄戏美人
- 2021-02-06 08:40
主要有两种原因。
第一种情形是最普通的。比如main.xml如下,其中有一个listview,其id为lv_contactbook
[html] view plaincopy
如果在activity对应的代码中,是这样的写的:
[java] view plaincopy
@override
public void oncreate(bundlesavedinstancestate)
{
super.oncreate(savedinstancestate);
listviewlv = (listview)findviewbyid(r.id.lv_contactbook);
setcontentview(r.layout.main);
//…
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯