added in version 22.1.0
belongs to Maven artifact
Deprecated since version 27.1.0


public class DetailsFragment
extends BaseFragment


This class was deprecated in API level 27.1.0.
use DetailsSupportFragment

A fragment for creating Leanback details screens.

A DetailsFragment renders the elements of its ObjectAdapter as a set of rows in a vertical list.The Adapter's PresenterSelector must maintain subclasses of RowPresenter.

When FullWidthDetailsOverviewRowPresenter is found in adapter, DetailsFragment will setup default behavior of the DetailsOverviewRow:
  • The alignment of FullWidthDetailsOverviewRowPresenter is setup in setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter).
  • The view status switching of FullWidthDetailsOverviewRowPresenter is done in onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter, FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int).
  • The recommended activity themes to use with a DetailsFragment are

  • Theme_Leanback_Details with activity shared element transition for FullWidthDetailsOverviewRowPresenter.
  • Theme_Leanback_Details_NoSharedElementTransition if shared element transition is not needed, for example if first row is not rendered by FullWidthDetailsOverviewRowPresenter.
  • DetailsFragment can use DetailsFragmentBackgroundController to add a parallax drawable background and embedded video playing fragment.


    Inherited constants

    From interface android.content.ComponentCallbacks2

    Public constructors


    Public methods

    ObjectAdapter getAdapter()

    Returns the list of rows.

    BaseOnItemViewClickedListener getOnItemViewClickedListener()

    Returns the item clicked listener.

    DetailsParallax getParallax()

    Returns the DetailsParallax instance used by DetailsFragmentBackgroundController to configure parallax effect of background and control embedded video playback.

    RowsFragment getRowsFragment()

    Gets embedded RowsFragment showing multiple rows for DetailsFragment.

    void onCreate(Bundle savedInstanceState)
    View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    View onInflateTitleView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)

    Called by installTitleView(LayoutInflater, ViewGroup, Bundle) to inflate title view.

    void onStart()
    void onStop()
    void setAdapter(ObjectAdapter adapter)

    Sets the list of rows for the fragment.

    void setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)

    Sets an item clicked listener.

    void setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)

    Sets an item selection listener.

    void setSelectedPosition(int position)

    Sets the selected row position with smooth animation.

    void setSelectedPosition(int position, boolean smooth)

    Sets the selected row position.

    Protected methods

    Object createEntranceTransition()

    Create entrance transition.

    View inflateTitle(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)

    This method was deprecated in API level 24.1.0. override onInflateTitleView(LayoutInflater, ViewGroup, Bundle) instead.

    void onEntranceTransitionEnd()

    Callback when entrance transition is ended.

    void onEntranceTransitionPrepare()

    Callback when entrance transition is prepared.

    void onEntranceTransitionStart()

    Callback when entrance transition is started.

    void onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter presenter, FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder, int adapterPosition, int selectedPosition, int selectedSubPosition)

    Called to change DetailsOverviewRow view status when current selected row position or selected sub position changed.

    void onSetRowStatus(RowPresenter presenter, RowPresenter.ViewHolder viewHolder, int adapterPosition, int selectedPosition, int selectedSubPosition)

    Called on every visible row to change view status when current selected row position or selected sub position changed.

    void runEntranceTransition(Object entranceTransition)

    Run entrance transition.

    void setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter presenter)

    Called to setup FullWidthDetailsOverviewRowPresenter.

    void setupPresenter(Presenter rowPresenter)

    Called to setup each Presenter of Adapter passed in setAdapter(ObjectAdapter).Note that setup should only change the Presenter behavior that is meaningful in DetailsFragment.

    Inherited methods

    From class
    From class