I have a viewPager.
Say underlying dataset is d0,d1,d2,d3,etc, and corresponding fragments are f0,f1,f2,f3...
Currently Fragment f1 is visible i.e. position 1 of ViewPager
. d0, is removed and notifyDataSetChanged
is called on the adapter.
Now, the current visible fragment will become f2 i.e. f2 will be in position 1, while f1 will be in position 0, of ViewPager
I want that f1 to remain visible after the change in the dataset, i.e., ViewPager
should show Fragment
corresponding to position 0.
How to achieve this?
Edit : Currently, I am using viewpager.setCurrentItem(int position)
to achieve this, but it has jerky UI experience. The changing of the viewPager
items is visible to the user.