0

I created tabbed activity using view pager with three fragments (f1,f2,f3), if I made changes to f1 then when I slide f2 get back out won't lose the data but when I slide to f3 the changes on f1 were lost ,I want all the data to persist while sliding, how to do that ?

Henok
  • 3,293
  • 4
  • 15
  • 36
  • 3
    Possible duplicate of [Data Persistence ViewPager](http://stackoverflow.com/questions/14660441/data-persistence-viewpager) – Parth Sane Nov 19 '16 at 15:03

1 Answers1

2

Try to change Offset Page Limit of your viewPager like below.

mViewPager.setOffscreenPageLimit(3);

This method:

Sets the number of pages that should be retained to either side of the current page in the view hierarchy in an idle state.

https://developer.android.com/reference/android/support/v4/view/ViewPager.html

Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52