Does Not Have A Navcontroller Set On 2131231008

[Solved] Does Not Have A Navcontroller Set On 2131231008 | Swift - Code Explorer | yomemimo.com
Question : does not have a NavController set

Answered by : gurmeet-singh-dhillon

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

Source : https://qa.ostack.cn/qa/?qa=494097/ | Last Update : Tue, 03 May 22

Question : does not have a NavController set on 2131231008

Answered by : hbalhassan

// activity_main.xml
<fragment android:layout_width="match_parent" android:layout_height="match_parent" android:name="androidx.navigation.fragment.NavHostFragment" android:id="@+id/nav_host_fragment" app:navGraph="@navigation/mobile_navigation" />
// MainActivity.kt
val toolbar = findViewById<MaterialToolbar>(R.id.main_toolbar)
setSupportActionBar(toolbar)

Source : | Last Update : Mon, 31 May 21

Question : does not have a NavController set

Answered by : gurmeet-singh-dhillon

<androidx.fragment.app.FragmentContainerView android:id="@+id/nav_host_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_toBottomOf="parent" app:navGraph="@navigation/nav_graph" />

Source : https://qa.ostack.cn/qa/?qa=494097/ | Last Update : Tue, 03 May 22

Answers related to does not have a navcontroller set on 2131231008

Code Explorer Popular Question For Swift