Reputation: 71
I have an Arraylist of items that I pass to a ViewPager adapter. I am having trouble processing the data since at the adapter's
public Object instantiateItem(@NonNull ViewGroup container, int position)
,
position 0 and 1 are loaded concurrently before the ViewPager switches to the second page.
Is this typical or am i missing something ?.
The Arraylist is loaded when calling the adapter i.e ,
mPhotoAdapter = new PhotoAdapter(mPhotos, this, this);
Upvotes: 0
Views: 281
Reputation: 1256
Yes, This is typical. ViewPager
loads another page even though you have not swiped into the other page. As per documentation ViewPager
require a minimum of 1 offscreen pages. That means minimum one extra page will be loaded. You can change offscreen page limit by calling this method in ViewPager
instance :
setOffscreenPageLimit (int limit)
Upvotes: 4