antonyt / InfiniteViewPager

Augment Android's ViewPager with wrap-around functionality.
MIT License
695 stars 194 forks source link

ViewPager sometimes displays 'empty' pages #23

Closed aeroechelon closed 8 years ago

aeroechelon commented 9 years ago

I've noticed that when you initialize a fragment with this ViewPager, navigate away then navigate 'Back'; an empty page is shown. After navigating back to this fragment, you can continue to swipe on the pager, then after X amount of items the view pager it against populated with more items.

Initializing a fragment with this ViewPager seems to work fine; however, coming back to a fragment that had already been created creates some blank pages.

tmmiller1982 commented 9 years ago

Any update on this? I'm seeing this same thing.

aeroechelon commented 9 years ago

@tmmiller1982, I fixed this issue by constructing the corresponding adapter, FragmentStatePagerAdapter with Fragment#getChildFragmentManager(). If you have a fragment within a fragment you need to construct this new fragment with a child fragment manager so it can handle the Back navigation appropriately.

It took me a while to figure this one out ... it should be documented somewhere in the Android Docs since the ubiquitous use of Fragments ...

tmmiller1982 commented 9 years ago

ah very nice. Good find!

quangtrung89 commented 8 years ago

Can you please show me the code how you change from FragmentPagerAdapter into FragmentStatePagerAdapter?

aeroechelon commented 8 years ago

You can populate this ViewPager with FragmentStatePagerAdapter provided by the SDK here.

ttgdz commented 7 years ago

I'm seeing this issue too,but I use view instead of fragment,and sometimes the page is blank...Any suggestions?

kasumbarobert commented 6 years ago

Did anyone get a solution to this?

asadmukhtar28 commented 6 years ago

Kindly Help me guys, i have a simple image silder implementation with Viewpager and using PagerAdapter my VIewpager show sometimes empty.

kevinjmz commented 5 years ago

Hello guys. I was having the same problem, then I noticed that I was creating multiple instances of my adapter, since it was being created and instantiated on OnViewCreated. To fix this I created a PagerAdapter global variable, then I instantiate the variable ONLY within OnCreateView. This fixed my issue of going back and creating new empty screens.

dbof10 commented 4 years ago

I'm having the same issue. it's more like google viewpager than this viewpager.