diff --git a/app/src/main/java/com/example/android/navigation/MainActivity.kt b/app/src/main/java/com/example/android/navigation/MainActivity.kt index acd028eb2..847e1864c 100644 --- a/app/src/main/java/com/example/android/navigation/MainActivity.kt +++ b/app/src/main/java/com/example/android/navigation/MainActivity.kt @@ -32,7 +32,9 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) @Suppress("UNUSED_VARIABLE") val binding = DataBindingUtil.setContentView(this, R.layout.activity_main) - val navController = this.findNavController(R.id.myNavHostFragment) + val navHostFragment = + supportFragmentManager.findFragmentById(R.id.myNavHostFragment) as NavHostFragment + val navController = navHostFragment.navController NavigationUI.setupActionBarWithNavController(this, navController) }