Reputation: 2731
Here is how my hierarchy looks like:
MainActivity -> Fragment -> Dialog -> ViewPager -> Fragment 1, 2, 3
Getting the SupportFragmentManager works by casting:
FragmentManager fragmentManager = ((AppCompatActivity) mContext).getSupportFragmentManager();
However I can't seem to get the ChildFragmentManager.
((AppCompatActivity) mContext).getChildFragmentManager()
is not valid.
Upvotes: 0
Views: 586
Reputation: 200020
A regular dialog doesn't have a FragmentManager
, so you could not add a Fragment based ViewPager
inside of it.
Instead, you should use a DialogFragment
as per the Dialogs documentation and override its onCreateDialog()
to create your Dialog
. In a DialogFragment
, you can use getChildFragmentManager()
with a ViewPager.
Upvotes: 1