I got a ViewPager
which holds Fragment
s via FragmentStatePagerAdapter
. Let's say the pager initially holds the following pages (Fragment
s):
A - B - C - D
When the user swipes, he can move from A
to B
, B
to C
etc.
But there are cases when the user changes some options on the A
page, he can move not to B
, but C
:
A - C - D
Then the user goes back to A
, modifies something and that re-enables B
:
A - B - C - D
How can i achieve this very dynamic behavior? I cannot add Fragment
s any time when the user changes something and then re-populate the ViewPager
, because it's slow and breaks the flow.
ListView
, you can simply update theFragmentStatePagerAdapter
behind yourViewPager
with different data. Give theAdapter
a different set ofFragments
in each case. – SphacelusnotifyDatasetChanged
, theViewPager
recreates the whole list ofFragment
s, and the jumps to the first page, also everyFragment
loses the state. – Quadri