androidandroid-fragmentscalendarandroid-viewpagerpagerslidingtabstrip

How to get ViewPager working with dates?


Basically I'm trying to create finite sliding tabs (say, 2 weeks). The middle tab is the current date, You can't scroll into future dates, but can go back as far as the tabs will take you. This should be based on a calendar (legit dates, etc.) and look like a timeline. A good example is the Fitocracy app, which I'm trying to imitate.

Any ideas are greatly appreciated!


Solution

  • Look at this Infinite ViewPager lib (sample below) and PagerSlidingTabStrip lib for smooth tabs names.

    //XML
    <com.antonyt.infiniteviewpager.InfiniteViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
    // Code
    PagerAdapter wrappedAdapter = new InfinitePagerAdapter(yourFragmentPagerAdapter);
    viewPager.setAdapter(wrappedAdapter);
    

    I think that using 2 libs above is enough to achieve what you want.