I have a ViewPager which swipes between Fragments. I\'m using a FragmentStatePagerAdapter to feed the Fragments to the ViewPager. If the user swipes left at a normal pace, and t
For now, I suspect two methods.
1) In the fragment code:
@Override
public int getCount()
{
return mBagels.size();
}
Note: getCount()
should return the number of fragments instead of the size of the list. I could not tell how many of fragments you will have. Perhaps you have to keep track in the Adapter.
2) Another, I suspect getItem()
method and the use of newInstance
(). The related specific code:
FragmentProfile fragment = FragmentProfile.newInstance(mBagels.get(i),...
Notes:
According to Google webpage FragmentStatePagerAdapter, method newInstance
should create a new fragment probably because that's when the FragmentStatePagerAdapter does not have the fragment in memory yet OR was released from memory.
Perhaps post the code related to FragmentProfile.newInstance
especially if you disagree with my statement above.