Harsha M V
Harsha M V

Reputation: 54949

Android Tabs Content for better User Experience

I have an Activity which has 3 tabs which are Fragments.

  1. Featured
  2. Up Coming
  3. Favorites

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

Answers (2)

twocity
twocity

Reputation: 666

This is a feature of ViewPager

Upvotes: 1

zennon
zennon

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

Related Questions