我试图从零开始了解RecyclerView,因此我尝试使用它创建一个视图。但是,一旦我尝试打开活动,似乎就会出现错误:Error inflating class android.v7.widget.RecyclerView或class android.v7.widget.RecyclerView not found。
我尝试更改依赖关系,更新sdktargets,检查了正确的导入并尝试了所有以前可用的帮助。但是我仍然无法纠正或消除错误。因此,在关闭重复项并删除问题之前,请帮助我解决此错误。
这是我的build.gradle:
{
compileSdkVersion 26
defaultConfig {
applicationId "com.example.nysil.newsnow"
minSdkVersion 21
targetSdkVersion 26
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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:recyclerview-v7:26+'
}
Run Code Online (Sandbox Code Playgroud)
这是我的回收站视图的布局文件:
<android.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/recyclerView"
/>
Run Code Online (Sandbox Code Playgroud)
这是调试器显示的错误:
E/MultiWindowProxy: getServiceInstance failed!
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: …Run Code Online (Sandbox Code Playgroud)