我一直在使用android.support.v7.widget
软件包-特别是RecyclerView
类(其他问题除外,但这就是问题所在)。
直到今天早些时候,它都运行良好,现在看来它随机默认为该程序包的早期版本。我之所以这样说是因为:
myRecyclerView.addOnScrollListener(myScrollListener)
,myRecyclerView.getChildAdapterPosition(myView)
等Android Studio中给出了编译错误Cannot resolve method ...
。myRecyclerView.setOnScrollListener(myScrollListener)
(即使用set
代替add
),它可以正常工作,并且不会显示不赞成使用的错误,这应该是因为方法不赞成使用。我不知道为什么当我一直在使用并且能够较早地使用这些方法进行编译时,现在却显示错误-似乎好像是在使用早期版本的android.support.v7.widget
库,但是我不知道为什么会这样做或如何修理它...
编辑:我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.app"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.1'
compile 'com.github.rey5137:material:1.1.1'
compile 'com.android.support:design:22.2.0'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.rengwuxian.materialedittext:library:2.1.3'
}
我不确定,如何导入它,但是如果要使用RecyclerView,则需要添加其依赖项,即编译 'com.android.support:recyclerview-v7:22.2.0'
我看不到您是否已向RecyclerView
gradle脚本添加依赖项。另外,请记住,它不是appcompat软件包随附的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句