Reputation: 54949
I have an Activity which has 3 tabs which are Fragments.
Right now my implement when i click a particular tab it downloads the content from the internet and displays it.
When i was browsing through the Google Play App. I found that when i went into the App section All the content across the tabs Featured - Top Free - Top Paid etc
was already there and only the images was lazy loading.
I am trying figure out how this can be implemented.
Upvotes: 1
Views: 75
Reputation: 1090
In my app i have a Activity wich has 4 Tabs wich are Fragments..
I solved your explained Problem by Using a Singleton. I load all relevant information from sqlite database and pass it into an ArrayList in the Singletion.. So i can access the content from every Fragment...
public class Singleton {
private static Singleton instance = null;
public ArrayList<MyObject> myObjectList;
protected Singleton() {
// Exists only to defeat instantiation.
}
public static Singleton getInstance() {
if(instance == null) {
instance = new Singleton();
myObjectList = new ArrayList<MyObject>();
}
return instance;
}
}
Upvotes: 2