How To Stop Reloading Of A Tab Fragment While Swiping
I am creating Tabs during RunTime.Depends on the Json data category count, fragment is created.Even products are listed depends on Category. My issue is that while I swipe the prev
Solution 1:
First of all, using viewPager.setOffscreenPageLimit(jSonTab.size());
is not good. Suppose jSonTab.size()
returns 8 or more
. Then 8+ fragments
will remain in your memory. This will increase your memeory Consumption or may get OurOfMemoryError.
By Default OffScreenPageLimit is 2
. so when swipe for next fragment. it onStop()
method of OffScreen fragments is called.
When you get back to those fragments. all lifecycle is repeated. and OnActivityCreated()
is called before onCreateView()
.
So it is possible that when you return back to those fragments. The sequence you are using to set up data on you Fragment
is messed up.
So confirm it once. It may help you.
Post a Comment for "How To Stop Reloading Of A Tab Fragment While Swiping"