膨胀类androidx.design.widget.NavigationView时出错
我没有在StorageActivity中初始化组件,因为我认为问题就在那里,当我重新运行程序时,仍然出现了相同的错误。请原谅我的英语 注意:我使用的是androidX 运行时异常:无法启动活动 ComponentInfo{com.example.shopeproject/com.example.shopeproject.StorageActivity}: android.view.InflateException:二进制XML文件行#23:二进制XML 文件行#23:膨胀类时出错膨胀类androidx.design.widget.NavigationView时出错,android,androidx,android-navigationview,material-components,material-components-android,Android,Androidx,Android Navigationview,Material Components,Material Components Android,我没有在StorageActivity中初始化组件,因为我认为问题就在那里,当我重新运行程序时,仍然出现了相同的错误。请原谅我的英语 注意:我使用的是androidX 运行时异常:无法启动活动 ComponentInfo{com.example.shopeproject/com.example.shopeproject.StorageActivity}: android.view.InflateException:二进制XML文件行#23:二进制XML 文件行#23:膨胀类时出错 android
androidx.design.widget.NavigationView 我的XML文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StorageActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
<androidx.design.widget.NavigationView
app:headerLayout="@layout/drawer_header"
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:itemIconTint="#000000"
app:itemTextColor="#000000"
app:menu="@menu/menu">
</androidx.design.widget.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout >
如果迁移到androidX,则必须使用材质组件:
com.google.android.material.navigation.NavigationView
因为没有包含“androidx.design.widget.NavigationView”的库 要使用材质组件,必须在渐变中包含相关性:
implementation 'com.google.android.material:material:1.0.0'
androidx.design.widget.NavigationView不存在。