XvKnightvX
XvKnightvX

Reputation: 609

Viewpager in DialogFragment Doesn't Work

Sorry for the broad title but i have a viewpager and tablayout inside a dialog fragment but its not functioning properly. The first major issue is that the tabs appear at the top however the fragments that are supposed to appear in the tab arent there. The second issue is that when im swiping to another tab if i swipe then it does not move to the "closest" tab based on the indicator in fact the indicator just stays there (so for example if i swipe to the next tab the indicator wont move to the closest tab however i dont know if the indicator is accurate due to the fragments not showing). Sorry if this is a bit confusing to read but i dont really know how else to describe it. Thank you for any help in advance!!!

Upvotes: 0

Views: 781

Answers (1)

XvKnightvX
XvKnightvX

Reputation: 609

I Found the issue before i was trying to use the support fragment manager of the activity that launched the dialog fragment, after i switched to child fragment manager it fixed everything.

Basically i fixed the issue by changing this:

viewPagerAdapter = new ViewPageAdapter(getActivity().getSupportFragmentManager());

To this:

viewPagerAdapter = new ViewPageAdapter(getChildFragmentManager());

Upvotes: 1

Related Questions