title: Error While Implementing Bottom Navigation bar in Android Kotlin
body: <p>I am fairly new in android development.
  I tried implementing navigation bar in my app which switch from fragment A to Fragment B.
  And in Fragment A there is a floating action button which points to Fragment c.
  I have no problem switching from fragment A to B through navigation bar but when i try to switch to fragment c from Floating action button it gives me ERROR.</p>
  <p><strong>java.lang.IllegalStateException: View androidx.constraintlayout.widget.ConstraintLayout{65bf79f V.E...... ........ 0,0-1080,1529 #7f0800b2 app:id/frameLayout} does not have a NavController set</strong></p>
  <p>Here is the codes:</p>
  <p><strong>MainActivity.kt</strong></p>
  <pre><code>class MainActivity : AppCompatActivity() {
  
      private lateinit var navController: NavController
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          val dateView = findViewById&lt;TextView&gt;(R.id.dateTextView)
          dateView.text = getMonth()
  
          val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_frag) as NavHostFragment
          navController = navHostFragment.navController
  
          setupActionBarWithNavController(navController)
  
          val chartFrag = ChartsFragment()
          val infoData = info_data()
  
          val botNav = findViewById&lt;BottomNavigationView&gt;(R.id.botNavigation)
          botNav.setOnNavigationItemSelectedListener {
              when(it.itemId){
                  R.id.menu_statement -&gt;{
                      setCurrentFragment(infoData)
                  }
                  R.id.menu_charts -&gt;{
                      setCurrentFragment(chartFrag)
                  }
              }
              true
          }
  
      }
  
  
      fun setCurrentFragment(fragment: Fragment) = supportFragmentManager.beginTransaction().apply{
          replace(R.id.nav_host_frag, fragment)
          commit()
      }
  
      fun getMonth():String{
          val calendar = Calendar.getInstance()
          val simpleDateFormat = SimpleDateFormat(&quot;MMM yyyy&quot;)
          val date = simpleDateFormat.format(calendar.time)
          return date
      }
      override fun onSupportNavigateUp(): Boolean {
          return navController.navigateUp() || super.onSupportNavigateUp()
      }
  }
  </code></pre>
  <p><strong>info_data.kt</strong></p>
  <pre><code>class info_data : Fragment() {
      val dataSet = dataSource().loadData()
      val adapter = RecyclerViewAdapter(dataSet)
  
      companion object{
          var income = 0.0
          var expense = 0.0
      }
  
      lateinit var navController: NavController
  
      override fun onCreateView(
          inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_info_data, container, false)
      }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
  
          val tvExpense = view.findViewById&lt;TextView&gt;(R.id.tvExpense)
          tvExpense.text = &quot;Expense : \n$ &quot;+expense.toString()
  
          val tvIncome = view.findViewById&lt;TextView&gt;(R.id.tvIncome)
          tvIncome.text = &quot;Income : \n$ &quot;+income.toString()
  
          val tvTotal = view.findViewById&lt;TextView&gt;(R.id.tvTotal)
          tvTotal.text = &quot;Total : \n$ &quot;+grandTotal().toString()
  
          val rv= view.findViewById&lt;RecyclerView&gt;(R.id.recyclerView)
          rv.adapter = adapter
          rv.layoutManager = LinearLayoutManager(activity)
  
          val floatingBtn = view.findViewById&lt;FloatingActionButton&gt;(R.id.fabBtn)
          floatingBtn.setOnClickListener(){
              goToNextScreen(view)
          }
      }
  
      fun goToNextScreen(view: View){
          navController = Navigation.findNavController(view)
          navController!!.navigate(R.id.action_info_data_to_form_data2)
      }
  
      fun grandTotal():Double{
          val inc = income
          val exp = expense
          val total = inc-exp
          return total
      }
  }
  </code></pre>
  <p>**Errors:
  at androidx.navigation.Navigation.findNavController(Navigation.java:84)</p>
  <p>at com.example.myapplication.info_data.goToNextScreen(info_data.kt:58)</p>
  <p>at com.example.myapplication.info_data.onViewCreated$lambda-0(info_data.kt:53)**</p>