Nar*_*ath 5 android android-fragments kotlin android-jetpack-navigation
我正在创建一个带有 BottomNavigationView 的应用程序。
我正在使用 JetpackNavigation 和 kotlin。
我已将 XML 设置为
<fragment
android:id="@+id/fragNavHost"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/bottomNavView"
app:navGraph="@navigation/bottom_nav_graph"
tools:layout_editor_absoluteX="0dp" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu">
Run Code Online (Sandbox Code Playgroud)
但我Replace the <fragment> tag with FragmentContainerView.从 Android Studio 建议中收到一条建议消息
该应用程序在使用 FragmentContainerView 时中断,但在使用 Fragment 时完美运行
我收到的错误是
Unable to start activity ComponentInfo{com.example.reportbusterclone/com.example.reportbusterclone.view.MainActivity}: java.lang.IllegalStateException: Activity com.example.reportbusterclone.view.MainActivity@f462d5a does not have a NavController set on 2131296446
Run Code Online (Sandbox Code Playgroud)
即使只有标签发生变化而没有其他变化。
| 归档时间: |
|
| 查看次数: |
235 次 |
| 最近记录: |