Android 我应该如何设置RecyclerView版本以匹配我的项目?
我尝试运行/编写一个RecyclerView示例已经有一段时间了,但没有成功。我想这与依赖项中使用的RecyclerView版本以及我的项目使用的Android版本有关。 目前,我正在尝试运行这个示例 它没有提到什么是compileSdkVersion、minSdkVersion等等。 不管怎样,这是我的gradle:Android 我应该如何设置RecyclerView版本以匹配我的项目?,android,android-recyclerview,Android,Android Recyclerview,我尝试运行/编写一个RecyclerView示例已经有一段时间了,但没有成功。我想这与依赖项中使用的RecyclerView版本以及我的项目使用的Android版本有关。 目前,我正在尝试运行这个示例 它没有提到什么是compileSdkVersion、minSdkVersion等等。 不管怎样,这是我的gradle: apply plugin: 'com.android.application' android { compileSdkVersion 29 buildTool
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.deluxe.example"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
同样在本例中,适配器导入了android.support.v7.widget.RecyclerView,我得到了一个错误:无法解析符号v7。因此,Android建议导入androidx.recyclerview.widget.recyclerview
问题:我的项目没有在MainActivity中加载RecyclerView-它会引发异常:
膨胀类android.support.v7.widget.RecyclerView时出错
虽然有类似的问题,但我无法解决我的问题
我是Android Studio的新手,所以有谁能建议我应该做些什么改变来运行这个Recycler/CardView示例吗?我已经试过几个例子了,但都没能运行——最近的和旧的。
我尝试使用安卓牛轧糖(7.0)和更高版本运行,但这不是强制性的。而我的Android Studio版本是3.5.1因为您使用的是Androidx(很好),那么您需要导入相应的工件:
实现“androidx.recyclerview:recyclerview:1.1.0-beta04”
(或现有的任何最新版本)
然后在您引用RecyclerView的所有地方,(提示:使用Android studio“查找”并搜索术语RecyclerView
,以查找和评估所有引用和提到的地方),并确保您引用的是新工件,例如:
在代码和
谢谢,我做了相应的修改,至少我能看到布局。不能;但是我不能运行这个应用程序。。我犯了不同的错误,我相信这与另一个问题有关。
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "com.google.android.material:material:1.1.0-alpha10"
<com.google.android.material.card.MaterialCardView