【问题标题】:android.view.InflateException: Binary XML file line #15: Binary XML file line #19: Error inflating class fragmentandroid.view.InflateException:二进制 XML 文件第 15 行:二进制 XML 文件第 19 行:膨胀类片段时出错
【发布时间】:2022-01-17 15:00:45
【问题描述】:

启动应用程序时出现错误。我的代码没有错误,但我仍然收到此错误。帮我解决一下。

android.view.InflateException: Binary XML file line #15: Binary XML file line #19: Error inflating class fragment

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/app_bar_main1">

    <fragment
        android:id="@+id/nav_host_fragment_content_main1"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"                        <---- THIS IS 15
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/mobile_navigation" />   <----THIS IS 19

</androidx.constraintlayout.widget.ConstraintLayout>

【问题讨论】:

    标签: runtime-error fragment inflate-exception


    【解决方案1】:

    我终于找到了真正的问题。我对视图模型有问题。发生此错误是因为片段中存在逻辑错误

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-16
      • 2016-03-11
      • 1970-01-01
      • 2014-08-13
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 2014-05-21
      相关资源
      最近更新 更多