二进制XML文件错误,导致RecyclerView膨胀

早上好,我正在寻求您的帮助。我不断收到此错误:

Binary XML file line #11: Error inflating class androidx.recyclerview.widget.RecyclerView

我已经在此网站上进行了许多回复,但我尚未纠正此问题。除其他外,我还添加了新的实现。我们将不胜感激。

谢谢

错误代码

java.lang.RuntimeException: Unable to start activity ComponentInfo{rslpf.pa.myapplication/rslpf.pa.myapplication.Mainactivity}: android.view.InflateException: Binary XML file line #11: Error inflating class androidx.recyclerview.widget.RecyclerView
    at android.app.activityThread.performLaunchactivity(activityThread.java:2325)
    at android.app.activityThread.handleLaunchactivity(activityThread.java:2387)
    at android.app.activityThread.access$800(activityThread.java:151)
    at android.app.activityThread$H.handleMessage(activityThread.java:1303)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.activityThread.main(activityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
 Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class androidx.recyclerview.widget.RecyclerView
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
    at androidx.appcompat.app.appcompatdelegateImpl.setContentView(appcompatdelegateImpl.java:555)
    at androidx.appcompat.app.AppCompatactivity.setContentView(AppCompatactivity.java:161)
    at rslpf.pa.myapplication.Mainactivity.onCreate(Mainactivity.java:32)

请在下面找到我的XML文件部分:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">



<androidx.recyclerview.widget.RecyclerView

    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"/>

</RelativeLayout>

等级依赖性:

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.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

//implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.recyclerview:recyclerview:1.1.0';

}

liu2820168long 回答:二进制XML文件错误,导致RecyclerView膨胀

@android:color / primary_text_dark是颜色选择器,应替换为您的颜色,而不要使用颜色选择器

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
    <androidx.recyclerview.widget.RecyclerView

        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF"/>
</RelativeLayout>
本文链接:https://www.f2er.com/2836415.html

大家都在问