3

How do I disable page pre loading in Viewpager??

I tried

viewPager.setOffscreenPageLimit(0) 

but it's not working.

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
최봉재
  • 4,039
  • 3
  • 16
  • 21

2 Answers2

1

use this viewPager.setOffscreenPageLimit(1) instead of viewPager.setOffscreenPageLimit(0) . because the minimum value of setOffscreenPageLimit() is 1.

Zahidul Islam
  • 3,180
  • 1
  • 25
  • 35
0

Have a look at this.

According to Ali Imran you can try this:

  1. First create a count variable in the adapter class
  2. second in the ViewPager Adapter make a public function say setCount()
  3. and in the override getCount() function of Adapter return the count variable
  4. now override the on pageScroll() function of the ViewPager when the user flips the page you can call the setCount() to increase the count of the count variable
  5. also check that if that the current index is last and page is scrolled to left
Community
  • 1
  • 1
TejjD
  • 2,571
  • 1
  • 17
  • 37