Reputation: 16405
I have a master ActionBarActivity, that contains a ViewPager and a associated ViewPager Adapter. When the code
@Override
public Fragment getItem(int position) {
return pageToFragment(position);
}
is called by swiping the view pager, is the function
@Override
public void onAttachFragment(Fragment fragment) {
super.onAttachFragment(fragment);
}
called?
Is this function called every time we swipe, or just the first time?
Upvotes: 0
Views: 3095
Reputation: 345
This will not help you any more, but I hope someone else will find this useful. Both functions should be called only once:
getItem()
is called, when the fragment has been instantiated the first time with instantiateItem()
. instantiateItem()
can be called more than once, namely every time, you select a tab with a fragment, that has been destroyed (for example due to the setOffscreenPageLimit()
-limit), but getItem()
will not be called a second time.
onAttachFragment()
is "called when a Fragment is being attached to this activity, immediately after the call to its Fragment.onAttach() method and before Fragment.onCreate()" (taken from here)
Upvotes: 1