# FragmentPagerAdapter

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-fragment:28.0.0-alpha1  
Summary:[Inherited Constants](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#inhconstants)\|[Ctors](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#)  

# FragmentPagerAdapter

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


abstract
class
FragmentPagerAdapter
`  
`


``

extends `[PagerAdapter](https://developer.android.com/reference/android/support/v4/view/PagerAdapter)`


``


`

|---|---|---------------------------------------------|
| java.lang.Object                                  |||
| ↳ | [android.support.v4.view.PagerAdapter](https://developer.android.com/reference/android/support/v4/view/PagerAdapter) ||
|   | ↳ | android.support.v4.app.FragmentPagerAdapter |

<br />

*** ** * ** ***

Implementation of[PagerAdapter](https://developer.android.com/reference/android/support/v4/view/PagerAdapter)that represents each page as a[Fragment](https://developer.android.com/reference/android/support/v4/app/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](https://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter).

When using FragmentPagerAdapter the host ViewPager must have a valid ID set.

Subclasses only need to implement[getItem(int)](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#getItem(int))and[getCount()](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#getCount())to have a working adapter.

Here is an example implementation of a pager containing fragments of lists:  

```
public class FragmentPagerSupport extends FragmentActivity {
    static final int NUM_ITEMS = 10;

    MyAdapter mAdapter;

    ViewPager mPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_pager);

        mAdapter = new MyAdapter(getSupportFragmentManager());

        mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);

        // Watch for button clicks.
        Button button = (Button)findViewById(R.id.goto_first);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(0);
            }
        });
        button = (Button)findViewById(R.id.goto_last);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(NUM_ITEMS-1);
            }
        });
    }

    public static class MyAdapter extends FragmentPagerAdapter {
        public MyAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return NUM_ITEMS;
        }

        @Override
        public Fragment getItem(int position) {
            return ArrayListFragment.newInstance(position);
        }
    }

    public static class ArrayListFragment extends ListFragment {
        int mNum;

        /**
         * Create a new instance of CountingFragment, providing "num"
         * as an argument.
         */
        static ArrayListFragment newInstance(int num) {
            ArrayListFragment f = new ArrayListFragment();

            // Supply num input as an argument.
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);

            return f;
        }

        /**
         * When creating, retrieve this instance's number from its arguments.
         */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mNum = getArguments() != null ? getArguments().getInt("num") : 1;
        }

        /**
         * The Fragment's UI is just a simple text view showing its
         * instance number.
         */
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
            View tv = v.findViewById(R.id.text);
            ((TextView)tv).setText("Fragment #" + mNum);
            return v;
        }

        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            setListAdapter(new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_list_item_1, Cheeses.sCheeseStrings));
        }

        @Override
        public void onListItemClick(ListView l, View v, int position, long id) {
            Log.i("FragmentList", "Item clicked: " + id);
        }
    }
}
```

The`R.layout.fragment_pager`resource of the top-level fragment is:  

```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:padding="4dip"
        android:gravity="center_horizontal"
        android:layout_width="match_parent" android:layout_height="match_parent">

    <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1">
    </android.support.v4.view.ViewPager>

    <LinearLayout android:orientation="horizontal"
            android:gravity="center" android:measureWithLargestChild="true"
            android:layout_width="match_parent" android:layout_height="wrap_content"
            android:layout_weight="0">
        <Button android:id="@+id/goto_first"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:text="@string/first">
        </Button>
        <Button android:id="@+id/goto_last"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:text="@string/last">
        </Button>
    </LinearLayout>
</LinearLayout>
```

The`R.layout.fragment_pager_list`resource containing each individual fragment's layout is:  

```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:drawable/gallery_thumb">

    <TextView android:id="@+id/text"
        android:layout_width="match_parent" android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/hello_world"/>

    <!-- The frame layout is here since we will be showing either
    the empty view or the list view.  -->
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >
        <!-- Here is the list. Since we are using a ListActivity, we
             have to call it "@android:id/list" so ListActivity will
             find it -->
        <ListView android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:drawSelectorOnTop="false"/>

        <!-- Here is the view to show if the list is emtpy -->
        <TextView android:id="@android:id/empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="No items."/>

    </FrameLayout>

</LinearLayout>
```

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                                                          ### Inherited constants                                                                                                                                                                                                                                                                                                                                                          |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#)From class` `[android.support.v4.view.PagerAdapter](https://developer.android.com/reference/android/support/v4/view/PagerAdapter)` ` |-------|------------------------------------------------------------------------------------------------------------------------------| | `int` | [POSITION_NONE](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#POSITION_NONE) <br />           | | `int` | [POSITION_UNCHANGED](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#POSITION_UNCHANGED) <br /> | |

|                                                                                                                                  ### Public constructors                                                                                                                                  ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[FragmentPagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#FragmentPagerAdapter(android.support.v4.app.FragmentManager))`(`[FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)` fm) ` |

|                                                                                                                                                                                                                                                                                                   ### Public methods                                                                                                                                                                                                                                                                                                   ||
|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                         | ` `[destroyItem](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#destroyItem(android.view.ViewGroup, int, java.lang.Object))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container, int position, Object object) ` Remove a page for the given position.                                                                                                                                                                                  |
| ` void`                                                                                         | ` `[finishUpdate](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#finishUpdate(android.view.ViewGroup))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container) ` Called when the a change in the shown pages has been completed.                                                                                                                                                                                                          |
| ` abstract `[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment) | ` `[getItem](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#getItem(int))`(int position) ` Return the Fragment associated with a specified position.                                                                                                                                                                                                                                                                                                                             |
| ` long`                                                                                         | ` `[getItemId](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#getItemId(int))`(int position) ` Return a unique identifier for the item at the given position.                                                                                                                                                                                                                                                                                                                    |
| ` Object`                                                                                       | ` `[instantiateItem](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#instantiateItem(android.view.ViewGroup, int))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container, int position) ` Create the page for the given position.                                                                                                                                                                                                         |
| ` boolean`                                                                                      | ` `[isViewFromObject](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#isViewFromObject(android.view.View, java.lang.Object))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, Object object) ` Determines whether a page View is associated with a specific key object as returned by[instantiateItem(ViewGroup, int)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.ViewGroup, int)). |
| ` void`                                                                                         | ` `[restoreState](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#restoreState(android.os.Parcelable, java.lang.ClassLoader))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state, ClassLoader loader) ` Restore any instance state associated with this adapter and its pages that was previously saved by[saveState()](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#saveState()).                         |
| ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)             | ` `[saveState](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#saveState())`() ` Save any instance state associated with this adapter and its pages that should be restored if the current UI state needs to be reconstructed.                                                                                                                                                                                                                                                    |
| ` void`                                                                                         | ` `[setPrimaryItem](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#setPrimaryItem(android.view.ViewGroup, int, java.lang.Object))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container, int position, Object object) ` Called to inform the adapter of which item is currently considered to be the "primary", that is the one show to the user as the current page.                                                                    |
| ` void`                                                                                         | ` `[startUpdate](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#startUpdate(android.view.ViewGroup))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container) ` Called when a change in the shown pages is going to start being made.                                                                                                                                                                                                      |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#)From class` `[android.support.v4.view.PagerAdapter](https://developer.android.com/reference/android/support/v4/view/PagerAdapter)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                             | ` `[destroyItem](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#destroyItem(android.view.View, int, java.lang.Object))`(`[View](https://developer.android.com/reference/android/view/View.html)` container, int position, Object object) ` *This method was deprecated in API level 22.1.0. Use[destroyItem(ViewGroup, int, Object)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#destroyItem(android.view.ViewGroup, int, java.lang.Object))*             | | ` void`                                                                             | ` `[destroyItem](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#destroyItem(android.view.ViewGroup, int, java.lang.Object))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container, int position, Object object) ` Remove a page for the given position.                                                                                                                                                                                            | | ` void`                                                                             | ` `[finishUpdate](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#finishUpdate(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` container) ` *This method was deprecated in API level 22.1.0. Use[finishUpdate(ViewGroup)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#finishUpdate(android.view.ViewGroup))*                                                                                                 | | ` void`                                                                             | ` `[finishUpdate](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#finishUpdate(android.view.ViewGroup))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container) ` Called when the a change in the shown pages has been completed.                                                                                                                                                                                                                    | | ` abstract int`                                                                     | ` `[getCount](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#getCount())`() ` Return the number of views available.                                                                                                                                                                                                                                                                                                                                                                        | | ` int`                                                                              | ` `[getItemPosition](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#getItemPosition(java.lang.Object))`(Object object) ` Called when the host view is attempting to determine if an item's position has changed.                                                                                                                                                                                                                                                                           | | ` CharSequence`                                                                     | ` `[getPageTitle](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#getPageTitle(int))`(int position) ` This method may be called by the ViewPager to obtain a title string to describe the specified page.                                                                                                                                                                                                                                                                                   | | ` float`                                                                            | ` `[getPageWidth](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#getPageWidth(int))`(int position) ` Returns the proportional width of a given page as a percentage of the ViewPager's measured width from (0.f-1.f\]                                                                                                                                                                                                                                                                      | | ` Object`                                                                           | ` `[instantiateItem](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.ViewGroup, int))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container, int position) ` Create the page for the given position.                                                                                                                                                                                                                   | | ` Object`                                                                           | ` `[instantiateItem](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.View, int))`(`[View](https://developer.android.com/reference/android/view/View.html)` container, int position) ` *This method was deprecated in API level 22.1.0. Use[instantiateItem(ViewGroup, int)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.ViewGroup, int))*                                                        | | ` abstract boolean`                                                                 | ` `[isViewFromObject](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#isViewFromObject(android.view.View, java.lang.Object))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, Object object) ` Determines whether a page View is associated with a specific key object as returned by[instantiateItem(ViewGroup, int)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.ViewGroup, int)).           | | ` void`                                                                             | ` `[notifyDataSetChanged](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#notifyDataSetChanged())`() ` This method should be called by the application if the data backing this adapter has changed and associated views should update.                                                                                                                                                                                                                                                     | | ` void`                                                                             | ` `[registerDataSetObserver](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#registerDataSetObserver(android.database.DataSetObserver))`(`[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)` observer) ` Register an observer to receive callbacks related to the adapter's data changing.                                                                                                                                                   | | ` void`                                                                             | ` `[restoreState](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#restoreState(android.os.Parcelable, java.lang.ClassLoader))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state, ClassLoader loader) ` Restore any instance state associated with this adapter and its pages that was previously saved by[saveState()](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#saveState()).                                   | | ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | ` `[saveState](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#saveState())`() ` Save any instance state associated with this adapter and its pages that should be restored if the current UI state needs to be reconstructed.                                                                                                                                                                                                                                                              | | ` void`                                                                             | ` `[setPrimaryItem](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#setPrimaryItem(android.view.ViewGroup, int, java.lang.Object))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container, int position, Object object) ` Called to inform the adapter of which item is currently considered to be the "primary", that is the one show to the user as the current page.                                                                              | | ` void`                                                                             | ` `[setPrimaryItem](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#setPrimaryItem(android.view.View, int, java.lang.Object))`(`[View](https://developer.android.com/reference/android/view/View.html)` container, int position, Object object) ` *This method was deprecated in API level 22.1.0. Use[setPrimaryItem(ViewGroup, int, Object)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#setPrimaryItem(android.view.ViewGroup, int, java.lang.Object))* | | ` void`                                                                             | ` `[startUpdate](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#startUpdate(android.view.ViewGroup))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` container) ` Called when a change in the shown pages is going to start being made.                                                                                                                                                                                                                | | ` void`                                                                             | ` `[startUpdate](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#startUpdate(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` container) ` *This method was deprecated in API level 22.1.0. Use[startUpdate(ViewGroup)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#startUpdate(android.view.ViewGroup))*                                                                                                     | | ` void`                                                                             | ` `[unregisterDataSetObserver](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#unregisterDataSetObserver(android.database.DataSetObserver))`(`[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)` observer) ` Unregister an observer from callbacks related to the adapter's data changing.                                                                                                                                                   | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### FragmentPagerAdapter

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
FragmentPagerAdapter (FragmentManager fm)
```

<br />

<br />

|           Parameters           ||
|------|--------------------------|
| `fm` | `FragmentManager` <br /> |

## Public methods

### destroyItem

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void destroyItem (ViewGroup container, 
                int position, 
                Object object)
```

Remove a page for the given position. The adapter is responsible for removing the view from its container, although it only must ensure this is done by the time it returns from[finishUpdate(ViewGroup)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#finishUpdate(android.view.ViewGroup)).

<br />

|                                                                                                      Parameters                                                                                                       ||
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `container` | `ViewGroup`: The containing View from which the page will be removed. <br />                                                                                                                             |
| `position`  | `int`: The page position to be removed. <br />                                                                                                                                                           |
| `object`    | `Object`: The same object that was returned by[instantiateItem(View, int)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.View, int)). <br /> |

### finishUpdate

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void finishUpdate (ViewGroup container)
```

Called when the a change in the shown pages has been completed. At this point you must ensure that all of the pages have actually been added or removed from the container as appropriate.

<br />

|                                             Parameters                                              ||
|-------------|----------------------------------------------------------------------------------------|
| `container` | `ViewGroup`: The containing View which is displaying this adapter's page views. <br /> |

### getItem

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Fragment getItem (int position)
```

Return the Fragment associated with a specified position.

<br />

|        Parameters        ||
|------------|--------------|
| `position` | `int` <br /> |

|                                           Returns                                           ||
|-------------------------------------------------------------------------------------|--------|
| [Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment) | <br /> |

### getItemId

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
long getItemId (int position)
```

Return a unique identifier for the item at the given position.

The default implementation returns the given position. Subclasses should override this method if the positions of items can change.

<br />

<br />

|                       Parameters                       ||
|------------|--------------------------------------------|
| `position` | `int`: Position within this adapter <br /> |

|                          Returns                          ||
|--------|---------------------------------------------------|
| `long` | Unique identifier for the item at position <br /> |

### instantiateItem

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Object instantiateItem (ViewGroup container, 
                int position)
```

Create the page for the given position. The adapter is responsible for adding the view to the container given here, although it only must ensure this is done by the time it returns from[finishUpdate(ViewGroup)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#finishUpdate(android.view.ViewGroup)).

<br />

|                                      Parameters                                       ||
|-------------|--------------------------------------------------------------------------|
| `container` | `ViewGroup`: The containing View in which the page will be shown. <br /> |
| `position`  | `int`: The page position to be instantiated. <br />                      |

|                                                                   Returns                                                                   ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------|
| `Object` | Returns an Object representing the new page. This does not need to be a View, but can be some other container of the page. <br /> |

### isViewFromObject

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean isViewFromObject (View view, 
                Object object)
```

Determines whether a page View is associated with a specific key object as returned by[instantiateItem(ViewGroup, int)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.ViewGroup, int)). This method is required for a PagerAdapter to function properly.

<br />

|                                Parameters                                ||
|----------|----------------------------------------------------------------|
| `view`   | `View`: Page View to check for association with`object` <br /> |
| `object` | `Object`: Object to check for association with`view` <br />    |

|                                 Returns                                  ||
|-----------|---------------------------------------------------------------|
| `boolean` | true if`view`is associated with the key object`object` <br /> |

### restoreState

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void restoreState (Parcelable state, 
                ClassLoader loader)
```

Restore any instance state associated with this adapter and its pages that was previously saved by[saveState()](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#saveState()).

<br />

|                                                                                    Parameters                                                                                    ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state`  | `Parcelable`: State previously saved by a call to[saveState()](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter#saveState()) <br /> |
| `loader` | `ClassLoader`: A ClassLoader that should be used to instantiate any restored objects <br />                                                                            |

### saveState

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Parcelable saveState ()
```

Save any instance state associated with this adapter and its pages that should be restored if the current UI state needs to be reconstructed.

<br />

|                                                        Returns                                                        ||
|----------------------------------------------------------------------------------|-------------------------------------|
| [Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | Saved state for this adapter <br /> |

### setPrimaryItem

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setPrimaryItem (ViewGroup container, 
                int position, 
                Object object)
```

Called to inform the adapter of which item is currently considered to be the "primary", that is the one show to the user as the current page. This method will not be invoked when the adapter contains no items.

<br />

|                                                                                                      Parameters                                                                                                       ||
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `container` | `ViewGroup`: The containing View from which the page will be removed. <br />                                                                                                                             |
| `position`  | `int`: The page position that is now the primary. <br />                                                                                                                                                 |
| `object`    | `Object`: The same object that was returned by[instantiateItem(View, int)](https://developer.android.com/reference/android/support/v4/view/PagerAdapter#instantiateItem(android.view.View, int)). <br /> |

### startUpdate

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void startUpdate (ViewGroup container)
```

Called when a change in the shown pages is going to start being made.

<br />

|                                             Parameters                                              ||
|-------------|----------------------------------------------------------------------------------------|
| `container` | `ViewGroup`: The containing View which is displaying this adapter's page views. <br /> |

-

  ## Annotations

  - [NotificationCompat.Action.SemanticAction](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.SemanticAction)
-

  ## Interfaces

  - [ActionBarDrawerToggle.Delegate](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.Delegate)
  - [ActionBarDrawerToggle.DelegateProvider](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.DelegateProvider)
  - [ActivityCompat.OnRequestPermissionsResultCallback](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback)
  - [ActivityCompat.PermissionCompatDelegate](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.PermissionCompatDelegate)
  - [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/support/v4/app/FragmentManager.BackStackEntry)
  - [FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener)
  - [LoaderManager.LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)
  - [NotificationCompat.Action.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Extender)
  - [NotificationCompat.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Extender)
  - [SharedElementCallback.OnSharedElementsReadyListener](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback.OnSharedElementsReadyListener)
  - [TaskStackBuilder.SupportParentable](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.SupportParentable)
-

  ## Classes

  - [ActionBarDrawerToggle](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle)
  - [ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat)
  - [ActivityManagerCompat](https://developer.android.com/reference/android/support/v4/app/ActivityManagerCompat)
  - [ActivityOptionsCompat](https://developer.android.com/reference/android/support/v4/app/ActivityOptionsCompat)
  - [AlarmManagerCompat](https://developer.android.com/reference/android/support/v4/app/AlarmManagerCompat)
  - [AppLaunchChecker](https://developer.android.com/reference/android/support/v4/app/AppLaunchChecker)
  - [AppOpsManagerCompat](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat)
  - [BundleCompat](https://developer.android.com/reference/android/support/v4/app/BundleCompat)
  - [DialogFragment](https://developer.android.com/reference/android/support/v4/app/DialogFragment)
  - [Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)
  - [Fragment.SavedState](https://developer.android.com/reference/android/support/v4/app/Fragment.SavedState)
  - [FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)
  - [FragmentContainer](https://developer.android.com/reference/android/support/v4/app/FragmentContainer)
  - [FragmentController](https://developer.android.com/reference/android/support/v4/app/FragmentController)
  - [FragmentHostCallback](https://developer.android.com/reference/android/support/v4/app/FragmentHostCallback)
  - [FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)
  - [FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)
  - [FragmentManagerNonConfig](https://developer.android.com/reference/android/support/v4/app/FragmentManagerNonConfig)
  - [FragmentPagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter)
  - [FragmentStatePagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter)
  - [FragmentTabHost](https://developer.android.com/reference/android/support/v4/app/FragmentTabHost)
  - [FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)
  - [FrameMetricsAggregator](https://developer.android.com/reference/android/support/v4/app/FrameMetricsAggregator)
  - [JobIntentService](https://developer.android.com/reference/android/support/v4/app/JobIntentService)
  - [ListFragment](https://developer.android.com/reference/android/support/v4/app/ListFragment)
  - [LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager)
  - [NavUtils](https://developer.android.com/reference/android/support/v4/app/NavUtils)
  - [NotificationCompat](https://developer.android.com/reference/android/support/v4/app/NotificationCompat)
  - [NotificationCompat.Action](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action)
  - [NotificationCompat.Action.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Builder)
  - [NotificationCompat.Action.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.WearableExtender)
  - [NotificationCompat.BigPictureStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigPictureStyle)
  - [NotificationCompat.BigTextStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigTextStyle)
  - [NotificationCompat.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder)
  - [NotificationCompat.CarExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender)
  - [NotificationCompat.CarExtender.UnreadConversation](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation)
  - [NotificationCompat.CarExtender.UnreadConversation.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation.Builder)
  - [NotificationCompat.DecoratedCustomViewStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.DecoratedCustomViewStyle)
  - [NotificationCompat.InboxStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.InboxStyle)
  - [NotificationCompat.MessagingStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle)
  - [NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle.Message)
  - [NotificationCompat.Style](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Style)
  - [NotificationCompat.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.WearableExtender)
  - [NotificationCompatExtras](https://developer.android.com/reference/android/support/v4/app/NotificationCompatExtras)
  - [NotificationCompatSideChannelService](https://developer.android.com/reference/android/support/v4/app/NotificationCompatSideChannelService)
  - [NotificationManagerCompat](https://developer.android.com/reference/android/support/v4/app/NotificationManagerCompat)
  - [RemoteInput](https://developer.android.com/reference/android/support/v4/app/RemoteInput)
  - [RemoteInput.Builder](https://developer.android.com/reference/android/support/v4/app/RemoteInput.Builder)
  - [ServiceCompat](https://developer.android.com/reference/android/support/v4/app/ServiceCompat)
  - [ShareCompat](https://developer.android.com/reference/android/support/v4/app/ShareCompat)
  - [ShareCompat.IntentBuilder](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentBuilder)
  - [ShareCompat.IntentReader](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentReader)
  - [SharedElementCallback](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback)
  - [TaskStackBuilder](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder)
-

  ## Exceptions

  - [Fragment.InstantiationException](https://developer.android.com/reference/android/support/v4/app/Fragment.InstantiationException)