Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load only one Fragment in ViewPager

I have used ViewPager with Fragment.
But it loads two pages at time.
Is there any way to load only one page in viewpager ?

like image 783
kirankk Avatar asked Jul 12 '13 09:07

kirankk


2 Answers

This might be the thing you are looking for:

  mPager.setOffscreenPageLimit(n); // where n is the number of offscreen pages you want to load.

**The minimum value of it can be "1" as you said. ** check this link and also read the comments.

like image 123
SKK Avatar answered Oct 05 '22 21:10

SKK


setOffScreenPageLimit method has a limit of minimum 1. If you'll try to set smaller limit than this, it will use its default value which is 1.

like image 26
Pawan Maheshwari Avatar answered Oct 05 '22 22:10

Pawan Maheshwari