|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.support.v4.view.PagerAdapter
android.support.v13.app.FragmentPagerAdapter
public abstract class FragmentPagerAdapter
Implementation of PagerAdapter
that
represents each page as a Fragment
that is persistently
kept in the fragment manager as long as the user can return to the page.
This version of the pager is best for use when there are a handful of
typically more static fragments to be paged through, such as a set of tabs.
The fragment of each page the user visits will be kept in memory, though its
view hierarchy may be destroyed when not visible. This can result in using
a significant amount of memory since fragment instances can hold on to an
arbitrary amount of state. For larger sets of pages, consider
FragmentStatePagerAdapter
.
When using FragmentPagerAdapter the host ViewPager must have a valid ID set.
Subclasses only need to implement getItem(int)
and PagerAdapter.getCount()
to have a working adapter.
Here is an example implementation of a pager containing fragments of lists:
The R.layout.fragment_pager
resource of the top-level fragment is:
The R.layout.fragment_pager_list
resource containing each
individual fragment's layout is:
Field Summary |
---|
Fields inherited from class android.support.v4.view.PagerAdapter |
---|
POSITION_NONE, POSITION_UNCHANGED |
Constructor Summary | |
---|---|
FragmentPagerAdapter(android.app.FragmentManager fm)
|
Method Summary | |
---|---|
void |
destroyItem(android.view.ViewGroup container,
int position,
java.lang.Object object)
|
void |
finishUpdate(android.view.ViewGroup container)
|
abstract android.app.Fragment |
getItem(int position)
Return the Fragment associated with a specified position. |
long |
getItemId(int position)
Return a unique identifier for the item at the given position. |
java.lang.Object |
instantiateItem(android.view.ViewGroup container,
int position)
|
boolean |
isViewFromObject(android.view.View view,
java.lang.Object object)
|
void |
restoreState(android.os.Parcelable state,
java.lang.ClassLoader loader)
|
android.os.Parcelable |
saveState()
|
void |
setPrimaryItem(android.view.ViewGroup container,
int position,
java.lang.Object object)
|
void |
startUpdate(android.view.ViewGroup container)
|
Methods inherited from class android.support.v4.view.PagerAdapter |
---|
destroyItem, finishUpdate, getCount, getItemPosition, getPageTitle, getPageWidth, instantiateItem, notifyDataSetChanged, registerDataSetObserver, setPrimaryItem, startUpdate, unregisterDataSetObserver |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FragmentPagerAdapter(android.app.FragmentManager fm)
Method Detail |
---|
public abstract android.app.Fragment getItem(int position)
public void startUpdate(android.view.ViewGroup container)
startUpdate
in class android.support.v4.view.PagerAdapter
public java.lang.Object instantiateItem(android.view.ViewGroup container, int position)
instantiateItem
in class android.support.v4.view.PagerAdapter
public void destroyItem(android.view.ViewGroup container, int position, java.lang.Object object)
destroyItem
in class android.support.v4.view.PagerAdapter
public void setPrimaryItem(android.view.ViewGroup container, int position, java.lang.Object object)
setPrimaryItem
in class android.support.v4.view.PagerAdapter
public void finishUpdate(android.view.ViewGroup container)
finishUpdate
in class android.support.v4.view.PagerAdapter
public boolean isViewFromObject(android.view.View view, java.lang.Object object)
isViewFromObject
in class android.support.v4.view.PagerAdapter
public android.os.Parcelable saveState()
saveState
in class android.support.v4.view.PagerAdapter
public void restoreState(android.os.Parcelable state, java.lang.ClassLoader loader)
restoreState
in class android.support.v4.view.PagerAdapter
public long getItemId(int position)
The default implementation returns the given position. Subclasses should override this method if the positions of items can change.
position
- Position within this adapter
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |