net.simonvt.menudrawer.samples
Class ViewPagerSample.PagerAdapter

java.lang.Object
  extended by android.support.v4.view.PagerAdapter
      extended by android.support.v4.app.FragmentPagerAdapter
          extended by net.simonvt.menudrawer.samples.ViewPagerSample.PagerAdapter
Enclosing class:
ViewPagerSample

public static class ViewPagerSample.PagerAdapter
extends android.support.v4.app.FragmentPagerAdapter

This is a helper class that implements the management of tabs and all details of connecting a ViewPager with associated TabHost. It relies on a trick. Normally a tab host has a simple API for supplying a View or Intent that each tab will show. This is not sufficient for switching between pages. So instead we make the content part of the tab host 0dp high (it is not shown) and the TabsAdapter supplies its own dummy view to show as the tab content. It listens to changes in tabs, and takes care of switch to the correct paged in the ViewPager whenever the selected tab changes.


Field Summary
 
Fields inherited from class android.support.v4.view.PagerAdapter
POSITION_NONE, POSITION_UNCHANGED
 
Constructor Summary
ViewPagerSample.PagerAdapter(android.support.v4.app.FragmentActivity activity)
           
 
Method Summary
 void addTab(Class<?> clss, android.os.Bundle args)
           
 int getCount()
           
 android.support.v4.app.Fragment getItem(int position)
           
 
Methods inherited from class android.support.v4.app.FragmentPagerAdapter
destroyItem, finishUpdate, instantiateItem, isViewFromObject, restoreState, saveState, setPrimaryItem, startUpdate
 
Methods inherited from class android.support.v4.view.PagerAdapter
destroyItem, finishUpdate, getItemPosition, getPageTitle, instantiateItem, notifyDataSetChanged, setPrimaryItem, startUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewPagerSample.PagerAdapter

public ViewPagerSample.PagerAdapter(android.support.v4.app.FragmentActivity activity)
Method Detail

getCount

public int getCount()
Specified by:
getCount in class android.support.v4.view.PagerAdapter

getItem

public android.support.v4.app.Fragment getItem(int position)
Specified by:
getItem in class android.support.v4.app.FragmentPagerAdapter

addTab

public void addTab(Class<?> clss,
                   android.os.Bundle args)


Copyright © 2012-2013. All Rights Reserved.