aleien
aleien

Reputation: 821

Lifecycle of ViewPager

What fragment lifecycle methods (onCreate, onViewCreate, onStart) are called after you setup ViewPager with, say, 10 fragments and call setCurrentItem(9)?

Will there be any difference if you call setCurrentItem(i, false)?

Upvotes: 0

Views: 988

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191844

What fragment lifecycle methods (onCreate, onViewCreate, onStart) are called after you setup ViewPager

Every lifecycle method you mentioned plus onAttach, onResume, and onActivityStarted are called. There is nothing about a ViewPager that affects that. Refer to this picture to see the Fragment lifecycle.

Will there be any difference if you call setCurrentItem(i, false)?

No, false does not affect the lifecycle. the only thing that false will do is transition immediately to the page instead of smoothly across the ViewPager.

The onPause, onStop, etc. methods may be called after you scroll out of view of a Fragment, but that was not part of your question. ..

Upvotes: 2

Related Questions