Reputation: 411
I have three fragments, lets say Fragment A, B and C. Those are in a sliding tabs layout.
Illustration here : http://image.noelshack.com/fichiers/2015/27/1435684108-fdsf.png
When i open the application, i'm on fragment A and i do a volley request in it. The list view on fragment A is populated by data that i get from volley response. No problems so far.
When i switch from fragment A to fragment B, and then go back to fragment A, nothing change : the list view is still populated and fragment is not recreated ( normal situation ).
The problem is when i switch from fragment A to fragment C, and then go back to fragment A : It seems like fragment A is recreated ( i have my blank screen with the loading spinner until volley request gives a response and populates the list view, like when i launch the application )
I can switch by clicking on each tab name or by a sliding gesture, the problem is still the same.
So my question is : Why is fragment A recreated when i switch from A to C and then go back to A, but is not recreated when i switch from A to B and go back to A.
Thank you people and sorry for bad english.
Upvotes: 0
Views: 93
Reputation: 83
Try to add this code
mCustomViewPager.setOffscreenPageLimit(3);
Which means the three fragment will be in the stack, and no need to recreate them.
Upvotes: 1