Devlight / InfiniteCycleViewPager

Infinite cycle ViewPager with two-way orientation and interactive effect.
Apache License 2.0
5.75k stars 831 forks source link

How to implement this from fragment #41

Open amitsri20 opened 7 years ago

amitsri20 commented 7 years ago

First of all thanks for creating such a cool library.

Tried creating this from activity worked fine but I when am trying to implement this from inside my fragment but could not get it working.

In Fragment implementation I implemented changing few things like:

final ViewPager viewPager = (ViewPager) view.findViewById(R.id.vp_main); viewPager.setAdapter(new MainPagerAdapter(getChildFragmentManager())); viewPager.setOffscreenPageLimit(2);

In HorizontalPagerFragment changed like:

final HorizontalInfiniteCycleViewPager horizontalInfiniteCycleViewPager = (HorizontalInfiniteCycleViewPager) view.findViewById(R.id.hicvp); horizontalInfiniteCycleViewPager.setAdapter(new HorizontalPagerAdapter(getParentFragment().getContext() ,getParentFragment().getActivity()));

also tried without using

getParentFragment()

but Viewpager content is not showing up.

dhirajpowar commented 6 years ago

Please check whether you have added container.addView(view) in instantiateItem method from HorizontalPagerAdapter(inherited from PagerAdpater)