I'm showing a dialog inside a fragment using childFragmentManager
or within an Activity using the supportFragmentManager
, in the process I would like to set the target fragment, like this:
val textSearchDialog = TextSearchDialogFragment.newInstance()
textSearchDialog.setTargetFragment(PlaceSearchFragment@this, 0)
But when running that code I get the error:
java.lang.IllegalStateException: Fragment
TextSearchDialogFragment{b7fce67 #0 0} declared target fragment
PlaceSearchFragment{f87414 #0 id=0x7f080078} that does not belong to
this FragmentManager!
I don't know how to access the FragmentManager
the navigation components are using to manage the showing of the fragment, is there a solution for this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…