Using FragmentContainerView with Navigation component?

前端 未结 3 1545
暖寄归人
暖寄归人 2021-01-31 14:05

After updating to Navigation 2.2.0-beta01 from the previous version, lint gives a warning about replacing the tag with FragmentContainerView<

3条回答
  •  鱼传尺愫
    2021-01-31 14:39

    There is still a bug that will thrown an exception if you simply replace fragment for . The fix, as of now, as stated by many google enginners in this bug thread is to change your code in your activity:

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

提交回复
热议问题