-1

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.

q126y
  • 1,589
  • 4
  • 18
  • 50

1 Answers1

0

Try to call viewpager.setCurrentItem(int position) with the position of the fragment you want.

Farhad
  • 12,178
  • 5
  • 32
  • 60