【发布时间】:2019-10-06 18:11:45
【问题描述】:
我尝试运行/编写 RecyclerView 示例已经有一段时间了,但没有成功。我想这与依赖项中使用的 RecyclerView 版本和我的项目使用的 Android 版本有关。 目前,我正在尝试运行此示例here。
没有提到compileSdkVersion、minSdkVersion等是什么。 无论如何,这是我的 gradle:
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 尽管here和here和here有类似的问题,但我无法解决我的问题。
我是 Android Studio 的新手,谁能建议我应该改变什么来运行这个 Recycler/CardView 示例?我已经尝试了几个示例,但无法运行其中的任何一个——最近的和旧的。 我正在尝试使用 Android Nougat(7.0) 和更高版本运行,但这不是强制性的。 我的 Android Studio 版本是 3.5.1
【问题讨论】:
标签: android android-recyclerview