i have an Activity which haves several Fragments and am using PagerAdapter for organising this Fragments , i got to know when my activity, loads all of my Fragment's codes also gets executed even when am at first Fragment at that time my whole codes of all fragment 2 or 3 also got executed which are in the onCreateView
of my Fragment so can we stop this behaviour i want to execute this codes only when user selects that particular fragment
Asked
Active
Viewed 969 times
0

remy boys
- 2,928
- 5
- 36
- 65
-
1See this thread, http://stackoverflow.com/questions/23133912/android-viewpager-update-off-screen-but-cached-fragments-in-viewpager – K Neeraj Lal May 25 '16 at 13:44
1 Answers
0
you can limit your pager by calling this method default load number is 3
yourPager.setOffscreenPageLimit([number of pages]);
if you want just one page without preload try this link by TejjD

Community
- 1
- 1

Mehdi Akbarian Rastaghi
- 485
- 6
- 26
-
` final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(0);` well tried this but still the same effect existing – remy boys May 25 '16 at 13:56
-