【发布时间】:2018-10-02 15:20:45
【问题描述】:
RecyclerView 没有如下图所示,我找不到
任何解决方案。
我尝试了什么:
- 重建
- 清理项目
- 使缓存失效
我的 build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.user.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
}
这是图片中显示的activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="8dp">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
【问题讨论】:
-
我将添加图片中显示的xml代码,但我无法添加更多代码,因为我没有编写任何其他代码。
-
您使用的是什么版本的 Android Studio?如果已经添加了 recyclerView 依赖项并且重建没有帮助,那可能是一个错误,您可以使用旧 API 依赖项(如 27.1.1)或新版本的 Android Studio(如金丝雀版本)。
-
在显示侧向下滚动此设计,您会发现错误和刷新选项。
-
@Mohsen 谢谢!您的帖子提醒我将 Android 升级到 3.2!现在它可以工作了,有时它可以很容易......:)
标签: android android-recyclerview