Skip to content

Commit

Permalink
[fix]: use FragmentContainerView
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse205 authored Oct 2, 2023
1 parent f238b5e commit ac38d18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.f0x1d.logfox.NavGraphDirections
import com.f0x1d.logfox.R
Expand All @@ -35,7 +35,10 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

navController = findNavController(R.id.nav_host_fragment_content_main)
val navHostFragment = supportFragmentManager.findFragmentById(
R.id.nav_host_fragment_content_main
) as NavHostFragment
navController = navHostFragment.navController

binding.bottomNavigation?.setupWithNavController(navController)
binding.bottomNavigation?.setOnItemReselectedListener {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment_content_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment_content_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
Expand Down

0 comments on commit ac38d18

Please sign in to comment.