Heasung Kim Heasung Kim - 2 months ago 25
Android Question

ViewPager calls onPause() onResume()

When I using

ViewPager
with fragments
onPause()
,
onResume()
methods are called when moving to tabs which are far from the one more than 1 tabs.

I want to save all the fragments data so don't want to call
onPause()
,
onResume()
in the
Activity
.

How can I stop calling those functions?

Thank you

Answer

By default, the viewPager only keep in memory one fragment in each side.. is like this:

mViewPager.setOffscreenPageLimit(1);

You can increase that number, but be careful, you can easily run out of memory..

Comments