IllegalArgumentException: navigation destination xxx is unknown to this NavController

后端 未结 30 2282
遇见更好的自我
遇见更好的自我 2020-11-27 11:28

I am having issue with the new Android Navigation Architecture component when I try to navigate from one Fragment to another, I get this weird error:

30条回答
  •  -上瘾入骨i
    2020-11-27 12:26

    I have resolved the same problem by putting check before navigate instead of boilerplate code for clicking instantly control

     if (findNavController().currentDestination?.id == R.id.currentFragment) {
            findNavController().navigate(R.id.action_current_next)}
    /* Here R.id.currentFragment is the id of current fragment in navigation graph */
    

    according to this answer

    https://stackoverflow.com/a/56168225/7055259

提交回复
热议问题