Navigation Architecture Component - Dialog Fragments

后端 未结 10 679
[愿得一人]
[愿得一人] 2020-12-24 02:01

Is it possible to use the new Navigation Architecture Component with DialogFragment? Do I have to create a custom Navigator?

I would love to use them with the new fe

10条回答
  •  爱一瞬间的悲伤
    2020-12-24 02:42

    Yes it is possible, You can access view of parent fragment from dialog fragment by calling getParentFragment().getView() . And use the view for navigation.

    Here is the example

    Navigation.findNavController(getParentFragment().getView()).navigate(R.id.nextfragment);
    

提交回复
热议问题