Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
Android 0.0.0 Developer Preview
belongs to Maven artifact androidx.leanback:leanback:1.1.0-alpha01

PresenterSwitcher

public abstract class PresenterSwitcher
extends Object

java.lang.Object
   ↳ androidx.leanback.widget.PresenterSwitcher


An abstract helper class that switches a view in its parent view using a PresenterSelector. A subclass should implement insertView(View) to define how to add the view in parent, and may optionally override onViewSelected(View).

Summary

Public constructors

PresenterSwitcher()

Public methods

void clear()

Destroys created views.

final ViewGroup getParentViewGroup()

Returns the parent.

void init(ViewGroup parent, PresenterSelector presenterSelector)

Initializes the switcher with a parent view to insert view into and a PresenterSelector for choosing a Presenter for a given object.

void select(Object object)

Selects a view based on the given object and shows that view.

void unselect()

Hides the view.

Protected methods

abstract void insertView(View view)
void onViewSelected(View view)

Called when a view is bound to the object of select(Object).

void showView(View view, boolean visible)

Inherited methods

Public constructors

PresenterSwitcher

public PresenterSwitcher ()

Public methods

clear

public void clear ()

Destroys created views.

getParentViewGroup

public final ViewGroup getParentViewGroup ()

Returns the parent.

Returns
ViewGroup

init

public void init (ViewGroup parent, 
                PresenterSelector presenterSelector)

Initializes the switcher with a parent view to insert view into and a PresenterSelector for choosing a Presenter for a given object. This will destroy any existing views.

Parameters
parent ViewGroup

presenterSelector PresenterSelector

select

public void select (Object object)

Selects a view based on the given object and shows that view.

Parameters
object Object

unselect

public void unselect ()

Hides the view.

Protected methods

insertView

protected abstract void insertView (View view)

Parameters
view View

onViewSelected

protected void onViewSelected (View view)

Called when a view is bound to the object of select(Object).

Parameters
view View

showView

protected void showView (View view, 
                boolean visible)

Parameters
view View

visible boolean