【发布时间】:2021-12-28 11:59:03
【问题描述】:
我正在关注本教程RecyclerView in Android Studio Tutorial 并面临 Unresolved reference : recyclerview 错误。 我认为 gradle 文件中存在一些问题,但我无法解决。请帮助。 下面给出了完整的 gradle 文件以及 xml 代码的链接xml code
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 30
defaultConfig {
applicationId "com.example.newsapp"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
【问题讨论】:
-
请不要将代码作为图像包含在内,只需将其作为文本包含在此处即可。该示例很可能使用合成导入,因此只需使用 findViewById
-
@a_local_nobody 我在 recyclerView.layoutManager = LinearLayoutManager(this) 中有错误
-
这没有多大帮助,您能否编辑您的问题以包含相关代码?
标签: android kotlin android-recyclerview