我是目前正在研究RecycleView的android初学者。在build.gradle中添加recycleview依赖项后,我尝试将其添加到布局中,但是我的背景不是白色,因为它应该是黑色的,并在屏幕中间显示了文字androidx.recyclview。 widget.RecycleView。这和How to use androidx.recyclerview.widget.RecyclerView with tools:listitem?一样,我遵循那里给出的指示,但没有任何反应。有人知道问题出在哪里吗?
我的build.gradle文件
import com.google.gms.googleservices.GoogleServicesPlugin
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.faks_app"
minSdkVersion 25
targetSdkVersion 28
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"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
android x <androidx.recyclerview.widget.RecyclerView
中RecyclerView的标签
确保这就是您在XML中使用的内容。有时即使在预览中显示暗灰色+类名并不意味着它已损坏,有时它就像File-> Invalidate caches and restart,重新启动,清理项目并尝试运行应用程序一样简单。