ExpandableWidget
public interface ExpandableWidget
com.google.android.material.expandable.ExpandableWidget |
A widget that has expanded/collapsed state. When the expanded state changes, an event is dispatched
so that other widgets may react via a CoordinatorLayout.Behavior
.
Implementations of this interface should create an instance of ExpandableWidgetHelper
and forward all calls to it.
The expanded state can saved across configuration changes by implementing View.onSaveInstanceState()
and View.onRestoreInstanceState(Parcelable)
:
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); ExtendableSavedState state = new ExtendableSavedState(superState); state.extendableStates.put( "expandableWidgetHelper", expandableWidgetHelper.onSaveInstanceState()); return state; } @Override protected void onRestoreInstanceState(Parcelable state) { if (!(state instanceof ExtendableSavedState)) { super.onRestoreInstanceState(state); return; } ExtendableSavedState ess = (ExtendableSavedState) state; super.onRestoreInstanceState(ess.getSuperState()); expandableWidgetHelper.onRestoreInstanceState( ess.extendableStates.get("expandableWidgetHelper")); }
Summary
Public methods | |
---|---|
abstract boolean | isExpanded() Returns whether this widget is expanded. |
abstract boolean | setExpanded(boolean expanded) Sets the expanded state on this widget. |
Public methods
isExpanded
public abstract boolean isExpanded ()
Returns whether this widget is expanded.
Implementations should call ExpandableWidgetHelper.isExpanded()
.
Returns | |
---|---|
boolean |
setExpanded
public abstract boolean setExpanded (boolean expanded)
Sets the expanded state on this widget.
Implementations should call ExpandableWidgetHelper.setExpanded(boolean)
.
Parameters | |
---|---|
expanded | boolean |
Returns | |
---|---|
boolean | true if the expanded state changed as a result of this call. |