belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
Deprecated since version 27.1.0
BrowseFragment
public
class
BrowseFragment
extends BaseFragment
java.lang.Object | ||||
↳ | android.app.Fragment | |||
↳ | android.support.v17.leanback.app.BrandedFragment | |||
↳ | android.support.v17.leanback.app.BaseFragment | |||
↳ | android.support.v17.leanback.app.BrowseFragment |
This class was deprecated
in API level 27.1.0.
use BrowseSupportFragment
A fragment for creating Leanback browse screens. It is composed of a RowsFragment and a HeadersFragment.
A BrowseFragment renders the elements of its ObjectAdapter
as a set
of rows in a vertical list. The elements in this adapter must be subclasses
of Row
.
The HeadersFragment can be set to be either shown or hidden by default, or
may be disabled entirely. See setHeadersState(int)
for details.
By default the BrowseFragment includes support for returning to the headers
when the user presses Back. For Activities that customize onBackPressed()
, you must disable this default Back key support by
calling setHeadersTransitionOnBackEnabled(boolean)
with false and
use BrowseFragment.BrowseTransitionListener
and
startHeadersTransition(boolean)
.
The recommended theme to use with a BrowseFragment is
Theme_Leanback_Browse
.
Summary
Nested classes | |
---|---|
class |
BrowseFragment.BrowseTransitionListener
This class was deprecated
in API level 27.1.0.
use |
class |
BrowseFragment.FragmentFactory<T extends Fragment>
This class was deprecated
in API level 27.1.0.
use |
interface |
BrowseFragment.FragmentHost
This interface was deprecated
in API level 27.1.0.
use |
class |
BrowseFragment.ListRowFragmentFactory
This class was deprecated
in API level 27.1.0.
use |
class |
BrowseFragment.MainFragmentAdapter<T extends Fragment>
This class was deprecated
in API level 27.1.0.
use |
interface |
BrowseFragment.MainFragmentAdapterProvider
This interface was deprecated
in API level 27.1.0.
use |
class |
BrowseFragment.MainFragmentAdapterRegistry
This class was deprecated
in API level 27.1.0.
use |
class |
BrowseFragment.MainFragmentRowsAdapter<T extends Fragment>
This class was deprecated
in API level 27.1.0.
use |
interface |
BrowseFragment.MainFragmentRowsAdapterProvider
This interface was deprecated
in API level 27.1.0.
use |
Constants | |
---|---|
int |
HEADERS_DISABLED
The headers fragment is disabled and will never be shown. |
int |
HEADERS_ENABLED
The headers fragment is enabled and shown by default. |
int |
HEADERS_HIDDEN
The headers fragment is enabled and hidden by default. |
Inherited constants |
---|
From
interface
android.content.ComponentCallbacks2
|
Public constructors | |
---|---|
BrowseFragment()
|
Public methods | |
---|---|
static
Bundle
|
createArgs(Bundle args, String title, int headersState)
Creates arguments for a browse fragment. |
void
|
enableMainFragmentScaling(boolean enable)
Enables scaling of main fragment when headers are present. |
void
|
enableRowScaling(boolean enable)
This method was deprecated
in API level 24.1.0.
use |
ObjectAdapter
|
getAdapter()
Returns the adapter containing the rows for the fragment. |
int
|
getBrandColor()
Returns the brand color for the browse fragment. |
HeadersFragment
|
getHeadersFragment()
Get currently bound HeadersFragment or null if HeadersFragment has not been created yet. |
int
|
getHeadersState()
Returns the state of the headers column in the browse fragment. |
Fragment
|
getMainFragment()
|
final
BrowseFragment.MainFragmentAdapterRegistry
|
getMainFragmentRegistry()
|
OnItemViewClickedListener
|
getOnItemViewClickedListener()
Returns the item Clicked listener. |
OnItemViewSelectedListener
|
getOnItemViewSelectedListener()
Returns an item selection listener. |
RowsFragment
|
getRowsFragment()
Get RowsFragment if it's bound to BrowseFragment or null if either BrowseFragment has not been created yet or a different fragment is bound to it. |
int
|
getSelectedPosition()
Gets position of currently selected row. |
RowPresenter.ViewHolder
|
getSelectedRowViewHolder()
|
final
boolean
|
isHeadersTransitionOnBackEnabled()
Returns true if headers transition on back key support is enabled. |
boolean
|
isInHeadersTransition()
Returns true if the headers transition is currently running. |
boolean
|
isShowingHeaders()
Returns true if headers are shown. |
void
|
onCreate(Bundle savedInstanceState)
|
HeadersFragment
|
onCreateHeadersFragment()
Creates a new |
View
|
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
void
|
onDestroy()
|
void
|
onDestroyView()
|
void
|
onSaveInstanceState(Bundle outState)
|
void
|
onStart()
|
void
|
setAdapter(ObjectAdapter adapter)
Sets the adapter containing the rows for the fragment. |
void
|
setBrandColor(int color)
Sets the brand color for the browse fragment. |
void
|
setBrowseTransitionListener(BrowseFragment.BrowseTransitionListener listener)
Sets a listener for browse fragment transitions. |
void
|
setHeaderPresenterSelector(PresenterSelector headerPresenterSelector)
Sets the |
void
|
setHeadersState(int headersState)
Sets the state for the headers column in the browse fragment. |
final
void
|
setHeadersTransitionOnBackEnabled(boolean headersBackStackEnabled)
Enables/disables headers transition on back key support. |
void
|
setOnItemViewClickedListener(OnItemViewClickedListener listener)
Sets an item clicked listener on the fragment. |
void
|
setOnItemViewSelectedListener(OnItemViewSelectedListener listener)
Sets an item selection listener. |
void
|
setSelectedPosition(int position)
Sets the selected row position with smooth animation. |
void
|
setSelectedPosition(int rowPosition, boolean smooth, Presenter.ViewHolderTask rowHolderTask)
Selects a Row and perform an optional task on the Row. |
void
|
setSelectedPosition(int position, boolean smooth)
Sets the selected row position. |
void
|
startHeadersTransition(boolean withHeaders)
Starts a headers transition. |
Protected methods | |
---|---|
Object
|
createEntranceTransition()
Create entrance transition. |
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
|
runEntranceTransition(Object entranceTransition)
Run entrance transition. |
Inherited methods | |
---|---|
From
class
android.support.v17.leanback.app.BaseFragment
| |
From
class
android.support.v17.leanback.app.BrandedFragment
| |
From
class
android.app.Fragment
| |
From
class
java.lang.Object
| |
From
interface
android.content.ComponentCallbacks2
| |
From
interface
android.view.View.OnCreateContextMenuListener
| |
From
interface
android.content.ComponentCallbacks
|
Constants
HEADERS_DISABLED
int HEADERS_DISABLED
The headers fragment is disabled and will never be shown.
Constant Value: 3 (0x00000003)
HEADERS_ENABLED
int HEADERS_ENABLED
The headers fragment is enabled and shown by default.
Constant Value: 1 (0x00000001)
HEADERS_HIDDEN
int HEADERS_HIDDEN
The headers fragment is enabled and hidden by default.
Constant Value: 2 (0x00000002)
Public constructors
Public methods
createArgs
Bundle createArgs (Bundle args, String title, int headersState)
Creates arguments for a browse fragment.
Parameters | |
---|---|
args |
Bundle : The Bundle to place arguments into, or null if the method
should return a new Bundle. |
title |
String : The title of the BrowseFragment. |
headersState |
int : The initial state of the headers of the
BrowseFragment. Must be one of HEADERS_ENABLED , HEADERS_HIDDEN , or HEADERS_DISABLED . |
Returns | |
---|---|
Bundle |
A Bundle with the given arguments for creating a BrowseFragment. |
enableMainFragmentScaling
void enableMainFragmentScaling (boolean enable)
Enables scaling of main fragment when headers are present. For the page/row fragment,
scaling is enabled only when both this method and
isScalingEnabled()
are enabled.
Parameters | |
---|---|
enable |
boolean : true to enable row scaling
|
enableRowScaling
void enableRowScaling (boolean enable)
This method was deprecated
in API level 24.1.0.
use enableMainFragmentScaling(boolean)
instead.
Parameters | |
---|---|
enable |
boolean : true to enable row scaling
|
getAdapter
ObjectAdapter getAdapter ()
Returns the adapter containing the rows for the fragment.
Returns | |
---|---|
ObjectAdapter |
getBrandColor
int getBrandColor ()
Returns the brand color for the browse fragment. The default is transparent.
Returns | |
---|---|
int |
getHeadersFragment
HeadersFragment getHeadersFragment ()
Get currently bound HeadersFragment or null if HeadersFragment has not been created yet.
Returns | |
---|---|
HeadersFragment |
Currently bound HeadersFragment or null if HeadersFragment has not been created yet. |
getHeadersState
int getHeadersState ()
Returns the state of the headers column in the browse fragment.
Returns | |
---|---|
int |
getMainFragment
Fragment getMainFragment ()
Returns | |
---|---|
Fragment |
Current main fragment or null if not created. |
getMainFragmentRegistry
BrowseFragment.MainFragmentAdapterRegistry getMainFragmentRegistry ()
Returns | |
---|---|
BrowseFragment.MainFragmentAdapterRegistry |
getOnItemViewClickedListener
OnItemViewClickedListener getOnItemViewClickedListener ()
Returns the item Clicked listener.
Returns | |
---|---|
OnItemViewClickedListener |
getOnItemViewSelectedListener
OnItemViewSelectedListener getOnItemViewSelectedListener ()
Returns an item selection listener.
Returns | |
---|---|
OnItemViewSelectedListener |
getRowsFragment
RowsFragment getRowsFragment ()
Get RowsFragment if it's bound to BrowseFragment or null if either BrowseFragment has not been created yet or a different fragment is bound to it.
Returns | |
---|---|
RowsFragment |
RowsFragment if it's bound to BrowseFragment or null otherwise. |
getSelectedPosition
int getSelectedPosition ()
Gets position of currently selected row.
Returns | |
---|---|
int |
Position of currently selected row. |
getSelectedRowViewHolder
RowPresenter.ViewHolder getSelectedRowViewHolder ()
Returns | |
---|---|
RowPresenter.ViewHolder |
selected row ViewHolder inside fragment created by BrowseFragment.MainFragmentRowsAdapter .
|
isHeadersTransitionOnBackEnabled
boolean isHeadersTransitionOnBackEnabled ()
Returns true if headers transition on back key support is enabled.
Returns | |
---|---|
boolean |
isInHeadersTransition
boolean isInHeadersTransition ()
Returns true if the headers transition is currently running.
Returns | |
---|---|
boolean |
isShowingHeaders
boolean isShowingHeaders ()
Returns true if headers are shown.
Returns | |
---|---|
boolean |
onCreateHeadersFragment
HeadersFragment onCreateHeadersFragment ()
Creates a new HeadersFragment
instance. Subclass of BrowseFragment may override and
return an instance of subclass of HeadersFragment, e.g. when app wants to replace presenter
to render HeaderItem.
Returns | |
---|---|
HeadersFragment |
A new instance of HeadersFragment or its subclass.
|
onCreateView
View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Parameters | |
---|---|
inflater |
LayoutInflater |
container |
ViewGroup |
savedInstanceState |
Bundle |
Returns | |
---|---|
View |
onDestroy
void onDestroy ()
onDestroyView
void onDestroyView ()
onSaveInstanceState
void onSaveInstanceState (Bundle outState)
Parameters | |
---|---|
outState |
Bundle |
setAdapter
void setAdapter (ObjectAdapter adapter)
Sets the adapter containing the rows for the fragment.
The items referenced by the adapter must be be derived from
Row
. These rows will be used by the rows fragment and the headers
fragment (if not disabled) to render the browse rows.
Parameters | |
---|---|
adapter |
ObjectAdapter : An ObjectAdapter for the browse rows. All items must
derive from Row .
|
setBrandColor
void setBrandColor (int color)
Sets the brand color for the browse fragment. The brand color is used as the primary color for UI elements in the browse fragment. For example, the background color of the headers fragment uses the brand color.
Parameters | |
---|---|
color |
int : The color to use as the brand color of the fragment.
|
setBrowseTransitionListener
void setBrowseTransitionListener (BrowseFragment.BrowseTransitionListener listener)
Sets a listener for browse fragment transitions.
Parameters | |
---|---|
listener |
BrowseFragment.BrowseTransitionListener : The listener to call when a browse headers transition
begins or ends.
|
setHeaderPresenterSelector
void setHeaderPresenterSelector (PresenterSelector headerPresenterSelector)
Sets the PresenterSelector
used to render the row headers.
Parameters | |
---|---|
headerPresenterSelector |
PresenterSelector : The PresenterSelector that will determine
the Presenter for each row header.
|
setHeadersState
void setHeadersState (int headersState)
Sets the state for the headers column in the browse fragment. Must be one
of HEADERS_ENABLED
, HEADERS_HIDDEN
, or
HEADERS_DISABLED
.
Parameters | |
---|---|
headersState |
int : The state of the headers for the browse fragment.
|
setHeadersTransitionOnBackEnabled
void setHeadersTransitionOnBackEnabled (boolean headersBackStackEnabled)
Enables/disables headers transition on back key support. This is enabled by
default. The BrowseFragment will add a back stack entry when headers are
showing. Running a headers transition when the back key is pressed only
works when the headers state is HEADERS_ENABLED
or
HEADERS_HIDDEN
.
NOTE: If an Activity has its own onBackPressed() handling, you must
disable this feature. You may use startHeadersTransition(boolean)
and BrowseFragment.BrowseTransitionListener
in your own back stack handling.
Parameters | |
---|---|
headersBackStackEnabled |
boolean |
setOnItemViewClickedListener
void setOnItemViewClickedListener (OnItemViewClickedListener listener)
Sets an item clicked listener on the fragment.
OnItemViewClickedListener will override View.OnClickListener
that
item presenter sets during onCreateViewHolder(ViewGroup)
.
So in general, developer should choose one of the listeners but not both.
Parameters | |
---|---|
listener |
OnItemViewClickedListener |
setOnItemViewSelectedListener
void setOnItemViewSelectedListener (OnItemViewSelectedListener listener)
Sets an item selection listener.
Parameters | |
---|---|
listener |
OnItemViewSelectedListener |
setSelectedPosition
void setSelectedPosition (int position)
Sets the selected row position with smooth animation.
Parameters | |
---|---|
position |
int |
setSelectedPosition
void setSelectedPosition (int rowPosition, boolean smooth, Presenter.ViewHolderTask rowHolderTask)
Selects a Row and perform an optional task on the Row. For example
setSelectedPosition(10, true, new ListRowPresenterSelectItemViewHolderTask(5))
scrolls to 11th row and selects 6th item on that row. The method will be ignored if
RowsFragment has not been created (i.e. before onCreateView(LayoutInflater, ViewGroup, Bundle)
).
Parameters | |
---|---|
rowPosition |
int : Which row to select. |
smooth |
boolean : True to scroll to the row, false for no animation. |
rowHolderTask |
Presenter.ViewHolderTask : Optional task to perform on the Row. When the task is not null, headers
fragment will be collapsed.
|
setSelectedPosition
void setSelectedPosition (int position, boolean smooth)
Sets the selected row position.
Parameters | |
---|---|
position |
int |
smooth |
boolean |
startHeadersTransition
void startHeadersTransition (boolean withHeaders)
Starts a headers transition.
This method will begin a transition to either show or hide the headers, depending on the value of withHeaders. If headers are disabled for this browse fragment, this method will throw an exception.
Parameters | |
---|---|
withHeaders |
boolean : True if the headers should transition to being shown,
false if the transition should result in headers being hidden.
|
Protected methods
createEntranceTransition
Object createEntranceTransition ()
Create entrance transition. Subclass can override to load transition from resource or construct manually. Typically app does not need to override the default transition that browse and details provides.
Returns | |
---|---|
Object |
onEntranceTransitionEnd
void onEntranceTransitionEnd ()
Callback when entrance transition is ended.
onEntranceTransitionPrepare
void onEntranceTransitionPrepare ()
Callback when entrance transition is prepared. This is when fragment should stop user input and animations.
onEntranceTransitionStart
void onEntranceTransitionStart ()
Callback when entrance transition is started. This is when fragment should stop processing layout.
runEntranceTransition
void runEntranceTransition (Object entranceTransition)
Run entrance transition. Subclass may use TransitionManager to perform go(Scene) or beginDelayedTransition(). App should not override the default implementation of browse and details fragment.
Parameters | |
---|---|
entranceTransition |
Object |
Interfaces
- BrowseFragment.FragmentHost
- BrowseFragment.MainFragmentAdapterProvider
- BrowseFragment.MainFragmentRowsAdapterProvider
- BrowseSupportFragment.FragmentHost
- BrowseSupportFragment.MainFragmentAdapterProvider
- BrowseSupportFragment.MainFragmentRowsAdapterProvider
- HeadersFragment.OnHeaderClickedListener
- HeadersFragment.OnHeaderViewSelectedListener
- HeadersSupportFragment.OnHeaderClickedListener
- HeadersSupportFragment.OnHeaderViewSelectedListener
- SearchFragment.SearchResultProvider
- SearchSupportFragment.SearchResultProvider
Classes
- BackgroundManager
- BaseFragment
- BaseSupportFragment
- BrandedFragment
- BrandedSupportFragment
- BrowseFragment
- BrowseFragment.BrowseTransitionListener
- BrowseFragment.FragmentFactory
- BrowseFragment.ListRowFragmentFactory
- BrowseFragment.MainFragmentAdapter
- BrowseFragment.MainFragmentAdapterRegistry
- BrowseFragment.MainFragmentRowsAdapter
- BrowseSupportFragment
- BrowseSupportFragment.BrowseTransitionListener
- BrowseSupportFragment.FragmentFactory
- BrowseSupportFragment.ListRowFragmentFactory
- BrowseSupportFragment.MainFragmentAdapter
- BrowseSupportFragment.MainFragmentAdapterRegistry
- BrowseSupportFragment.MainFragmentRowsAdapter
- DetailsFragment
- DetailsFragmentBackgroundController
- DetailsSupportFragment
- DetailsSupportFragmentBackgroundController
- ErrorFragment
- ErrorSupportFragment
- GuidedStepFragment
- GuidedStepSupportFragment
- HeadersFragment
- HeadersSupportFragment
- OnboardingFragment
- OnboardingSupportFragment
- PlaybackFragment
- PlaybackFragmentGlueHost
- PlaybackSupportFragment
- PlaybackSupportFragmentGlueHost
- ProgressBarManager
- RowsFragment
- RowsFragment.MainFragmentAdapter
- RowsFragment.MainFragmentRowsAdapter
- RowsSupportFragment
- RowsSupportFragment.MainFragmentAdapter
- RowsSupportFragment.MainFragmentRowsAdapter
- SearchFragment
- SearchSupportFragment
- VerticalGridFragment
- VerticalGridSupportFragment
- VideoFragment
- VideoFragmentGlueHost
- VideoSupportFragment
- VideoSupportFragmentGlueHost
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.