Reputation: 1002
while using View pager, I face a strange problem. In my project i have three fragment in a view pager, but while loading the second fragment by swiping from left to right , the OnCreate of third Fragment is automatically calling.in onCreate method i called an Api for getting some data.hence the Api is also called.Normal scenario is like that it only called while loading third fragment by swiping from left to right.
Thanks in Advance
Upvotes: 0
Views: 849
Reputation: 823
View pager works same as listview. It have same buffer of fragments to increase the UI experience. so it creates fragments in advance and show to he user when asked.
so use http://developer.android.com/reference/android/support/v4/view/ViewPager.OnPageChangeListener.html for your purpose.
Thanks
Upvotes: 1