IT. Expert System.

Android Reference

FragmentStatePagerAdapter


android.support.v4.app

Class FragmentStatePagerAdapter



  • public abstract class FragmentStatePagerAdapter
    extends PagerAdapter
    Implementation of PagerAdapter that uses a Fragment to manage each page. This class also handles saving and restoring of fragment's state.

    This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.

    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:

    • Constructor Detail

      • FragmentStatePagerAdapter

        public FragmentStatePagerAdapter(FragmentManager fm)
    • Method Detail

      • getItem

        public abstract Fragment getItem(int position)
        Return the Fragment associated with a specified position.
      • startUpdate

        public void startUpdate(ViewGroup container)
        Description copied from class: PagerAdapter
        Called when a change in the shown pages is going to start being made.
        Overrides:
        startUpdate in class PagerAdapter
        Parameters:
        container - The containing View which is displaying this adapter's page views.
      • instantiateItem

        public Object instantiateItem(ViewGroup container,
                             int position)
        Description copied from class: PagerAdapter
        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 PagerAdapter.finishUpdate(ViewGroup).
        Overrides:
        instantiateItem in class PagerAdapter
        Parameters:
        container - The containing View in which the page will be shown.
        position - The page position to be instantiated.
        Returns:
        Returns an Object representing the new page. This does not need to be a View, but can be some other container of the page.
      • setPrimaryItem

        public void setPrimaryItem(ViewGroup container,
                          int position,
                          Object object)
        Description copied from class: PagerAdapter
        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.
        Overrides:
        setPrimaryItem in class PagerAdapter
        Parameters:
        container - The containing View from which the page will be removed.
        position - The page position that is now the primary.
        object - The same object that was returned by PagerAdapter.instantiateItem(View, int).
      • finishUpdate

        public void finishUpdate(ViewGroup container)
        Description copied from class: PagerAdapter
        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.
        Overrides:
        finishUpdate in class PagerAdapter
        Parameters:
        container - The containing View which is displaying this adapter's page views.
      • isViewFromObject

        public boolean isViewFromObject(View view,
                               Object object)
        Description copied from class: PagerAdapter
        Determines whether a page View is associated with a specific key object as returned by PagerAdapter.instantiateItem(ViewGroup, int). This method is required for a PagerAdapter to function properly.
        Specified by:
        isViewFromObject in class PagerAdapter
        Parameters:
        view - Page View to check for association with object
        object - Object to check for association with view
        Returns:
        true if view is associated with the key object object
      • saveState

        public Parcelable saveState()
        Description copied from class: PagerAdapter
        Save any instance state associated with this adapter and its pages that should be restored if the current UI state needs to be reconstructed.
        Overrides:
        saveState in class PagerAdapter
        Returns:
        Saved state for this adapter


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 3480 / 159204451. Delta: 0.05096 с