Reputation: 813
Im using these classes for my Tabs:
I have 3 Tabs : Tab1 Tab2 and Tab3.
In Tab3 Im loading contacts from my phone and add them into my ListView.This takes a while till it loaded successfuly (200 contacts).
Now my problem is : When I change my Tab from Tab3 to Tab1 the loading process begins again.So the Fragment is loading from zero again.
So everytime I change to Tab 1 and go back to Tab 3 everything has to be loaded again. Someone got an Idea to find a solution for it ? How can I prevent this Fragment reload ?
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.tab_friends, container, false);
LV_Contacts = (ListView)v.findViewById(R.id.LV_Contacts);
if(adapter_contacts == null)
new load_contacts().execute();
return v;
}
EDIT: When I change from Tab3 to Tab2 its working fine.It just continues but when I go to Tab1 everything starts from the beginning and it builds the Listview again
Upvotes: 0
Views: 924
Reputation: 786
all you need is to add this
viewPager.setOffscreenPageLimit(3);
for more detail read doc
Upvotes: 4