android - 使用 FragmentContainerView 和 NavHostFragment 时出错
问题描述
这是我在 xml 中的代码,
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_auth_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_graph_auth" />
我有例外
Caused by: android.view.InflateException: Binary XML file line #9 in activity_auth: Binary XML file line #9 in activity_auth: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #9 in activity_auth: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: java.lang.IllegalStateException: FragmentContainerView must have an android:id to add Fragment androidx.navigation.fragment.NavHostFragment
请帮助我,谢谢!
解决方案
推荐阅读
- javascript - 在不重新加载或分页更改的情况下刷新数据表内容
- ios - 在不阻塞主线程的情况下为 100 个 UIButtons 设置动画进度
- python - 每当我启动终端时如何修复错误?
- javascript - 如何正确导出从 NodeJS 中的 API 调用检索到的值
- python - 将图像的一部分放入 numpy 数组
- c# - 在打开的浏览器中激活标签(Opera/Chrome)
- node.js - 从节点调用时 ipinfo.io 错误 429
- prolog - Prolog-如何仅对另一个列表中的部分列表求和?
- python - 如何通过getsockopt知道“序列号”?
- reactjs - Redux - 从 action 中访问其他 reducer 的数据