ComponentParent, Text.TextObserverpublic class ListContainer extends ComponentContainer implements Text.TextObserver
This class inherits from ComponentContainer.
It uses BaseItemProvider to store objects.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
ListContainer.ItemClickedListener |
Listens for click events of
ListContainer items. |
static interface |
ListContainer.ItemLongClickedListener |
Provides the listener used to listen for and process long-click events of a
ListContainer item. |
static interface |
ListContainer.ItemSelectedListener |
Listens for selected events of a Component item in the
ListContainer object. |
static interface |
ListContainer.ItemVisibilityChangedListener |
Provides callbacks to be invoked when a component is added to or removed from the set of visible items.
|
static class |
ListContainer.ReboundEffectParams |
Represents rebound effect parameters.
|
static interface |
ListContainer.ScrollListener |
Represents an inner interface used to monitor the end of scrolling of a
ListContainer object. |
Component.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEventComponentContainer.ArrangeListener, ComponentContainer.LayoutConfig| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
INVALID_INDEX |
Indicates an invalid index.
|
static float |
ROTATION_SENSITIVITY_DEFAULT |
Indicates the default rotation sensitivity of
ListContainer to respond to rotating crown events. |
static float |
ROTATION_SENSITIVITY_HIGH |
Indicates the high rotation sensitivity of
ListContainer to respond to rotating crown events. |
static float |
ROTATION_SENSITIVITY_LOW |
Indicates the low rotation sensitivity of
ListContainer to respond to rotating crown events. |
ACCESSIBILITY_ADAPTABLE, ACCESSIBILITY_DISABLE, ACCESSIBILITY_ENABLE, AXIS_X, AXIS_Y, CONTOUR_BACKGROUND, CONTOUR_BORDER, CONTOUR_PADDING_BORDER, DEFAULT_SCALE, DRAG_DOWN, DRAG_HORIZONTAL, DRAG_HORIZONTAL_VERTICAL, DRAG_LEFT, DRAG_RIGHT, DRAG_UP, DRAG_VERTICAL, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR, EVENT_TYPE_COMPONENT_CLICKED, EVENT_TYPE_COMPONENT_FOCUSED, EVENT_TYPE_COMPONENT_LONG_CLICKED, EVENT_TYPE_COMPONENT_SCROLLED, EVENT_TYPE_COMPONENT_SELECTED, EVENT_TYPE_COMPONENT_TEXT_UPDATE, EVENT_TYPE_NOTICE, EVENT_TYPE_NOTIFICATION_STATE_UPDATE, EVENT_TYPE_TOAST_SHOW, EVENT_TYPE_WINDOW_STATE_UPDATE, FOCUS_ADAPTABLE, FOCUS_DISABLE, FOCUS_ENABLE, FOCUS_NEXT, FOCUS_PREVIOUS, FOCUS_SIDE_BOTTOM, FOCUS_SIDE_LEFT, FOCUS_SIDE_RIGHT, FOCUS_SIDE_TOP, HIDE, HORIZONTAL, ID_DEFAULT, INHERITED_MODE, INVISIBLE, mBackgroundElement, mCanvasForTaskOverContent, mCanvasForTaskUnderContent, mComponentParent, mContext, mDrawTaskOverContent, mDrawTaskUnderContent, mEstimateSizeListener, mForegroundElement, mForwardHoverListener, mHoverEventListener, mKeyEventListener, mMouseEventListener, mPosition, mRotationEventListener, mShadowElement, mUnconsumedKeyEventListener, OVAL_MODE, OVAL_SCROLL_BAR_MODE, POSITION_X_INDEX, POSITION_Y_INDEX, RECT_MODE, RECT_SCROLL_BAR_MODE, SCROLL_AUTO_STAGE, SCROLL_IDLE_STAGE, SCROLL_NORMAL_STAGE, UNSPECIFIED_SCROLL_BAR_MODE, VERTICAL, VISIBLEFOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener| 构造器 | 说明 |
|---|---|
ListContainer(Context context) |
Default constructor used to create a
ListContainer instance by using the default attribute set and style. |
ListContainer(Context context,
AttrSet attrSet) |
A constructor used to create a
ListContainer instance by using specified attribute set and default style
after the XML file is parsed. |
ListContainer(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
ListContainer instance by using specified attribute set and specified
style after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addComponent(Component childComponent) |
Adds a component to the end of the queue by invoking
ComponentContainer.addComponent(ohos.agp.components.Component,int index) internally. |
void |
addComponent(Component childComponent,
int index) |
Adds a component to the specified position.
|
void |
addComponent(Component childComponent,
int width,
int height) |
Adds a component and sets its width and height.
|
void |
addComponent(Component childComponent,
int index,
ComponentContainer.LayoutConfig layoutConfig) |
Adds a component and sets its layout parameters and location.
|
void |
addComponent(Component childComponent,
ComponentContainer.LayoutConfig layoutConfig) |
Adds a component and sets its layout parameters.
|
void |
addItemVisibilityChangedListener(ListContainer.ItemVisibilityChangedListener listener) |
Adds
ItemVisibilityChangedListener to the list of listeners. |
boolean |
executeItemClick(Component component,
int position,
long id) |
Processes a click event of a component item.
|
<T extends Component> |
findComponentById(int id) |
Finds the component with the given ID.
|
Element |
getBoundary() |
Obtains the
Element object used as the custom boundary of the list. |
Color |
getBoundaryColor() |
Obtains the boundary color of this
ListContainer object. |
boolean |
getBoundarySwitch() |
Specifies whether to enable boundary drawing.
|
int |
getBoundaryThickness() |
Obtains the thickness of boundary lines.
|
int |
getCenterFocusablePosition() |
Obtain the position index of the focusable item located in the component center.
|
int |
getChildCount() |
Obtains the total number of data items in a provider which can be set
via
setItemProvider(ohos.agp.components.BaseItemProvider). |
Component |
getComponentAt(int position) |
Obtains the Component from the set of visible items by position.
|
int |
getContentEndOffset() |
Obtains the end offset of a list container.
|
int |
getContentStartOffset() |
Obtains the start offset of a list container.
|
int |
getExtraItemsNumber() |
Obtains the number of extra items added to the top and bottom sides or left and right sides
(depending on the
ListContainer orientation) outside of the visible area. |
int |
getFirstVisibleItemPosition() |
已过时。
This change is effective since API version 5. Replaced by
getItemPosByVisibleIndex(int) |
boolean |
getFooterBoundarySwitch() |
Checks whether boundary drawing is enabled for footer components.
|
boolean |
getHeaderBoundarySwitch() |
Checks whether boundary drawing is enabled for header components.
|
int |
getIndexForComponent(Component component) |
Obtains the position of a
Component item in a ListContainer object. |
int |
getItemPosByVisibleIndex(int index) |
Obtains the position index of a visible item.
|
BaseItemProvider |
getItemProvider() |
Obtains the
BaseItemProvider object associated with a ListContainer object. |
int |
getLastVisibleItemPosition() |
已过时。
This change is effective since API version 5. Replaced by
getItemPosByVisibleIndex(int)
while passing the value equaling getVisibleIndexCount() minus 1. |
int |
getOrientation() |
Obtains an orientation of a layout.
|
boolean |
getReboundEffect() |
Obtains the state of the rebound effect.
|
ListContainer.ReboundEffectParams |
getReboundEffectParams() |
Obtains the rebound parameters as the
ReboundEffectParams object. |
int |
getSelectedItemIndex() |
Obtains the position of the selected component item.
|
Color |
getShaderColor() |
Obtains the shader color of this
ListContainer object. |
String |
getTextFilter() |
Obtains the text filter.
|
int |
getVisibleIndexCount() |
Obtains the size difference between the last and first visible items of the provider dataset.
|
void |
moveChildToFront(Component component) |
Brings a child component to the front.
|
protected boolean |
onItemLongClicked(ListContainer parent,
Component component,
int position,
long id) |
Called when a component item is long-clicked.
|
protected void |
onItemSelected(ListContainer parent,
Component component,
int position,
long id) |
Called when a component item in the
ListContainer object is selected. |
void |
onTextUpdated(String text,
int start,
int before,
int count) |
Called back when the text is changed.
|
void |
removeAllComponents() |
Clears all components managed by
ComponentContainer. |
void |
removeComponent(Component component) |
Removes a child component from the parent component.
|
void |
removeComponentAt(int index) |
Removes the component from a specified position in the component list.
|
void |
removeComponentById(int id) |
Removes a component based on its ID.
|
void |
removeComponents(int start,
int count) |
Removes all components from specified positions in a component list.
|
void |
removeItemVisibilityChangedListener(ListContainer.ItemVisibilityChangedListener listener) |
Removes
ItemVisibilityChangedListener from the list of listeners. |
void |
scrollTo(int position) |
Scrolls to the specified component item in a list container.
|
void |
scrollToCenter(int position) |
Scrolls specified item in a list container to center.
|
void |
setBoundary(Element boundary) |
Sets a
Element boundary that will be drawn between items in the list. |
void |
setBoundaryColor(Color color) |
Sets the boundary color for this
ListContainer object. |
void |
setBoundarySwitch(boolean boundaryEnabled) |
Sets whether to enable boundary drawing for components.
|
void |
setBoundaryThickness(int thickness) |
Sets the thickness of boundary lines.
|
void |
setContentEndOffSet(int endOffset) |
Sets the end offset for a list container.
|
void |
setContentOffSet(int startOffset,
int endOffset) |
Sets the start and end offsets for a list container.
|
void |
setContentStartOffSet(int startOffset) |
Sets the start offset for a list container.
|
void |
setExtraItemsNumber(int number) |
Sets the number of extra items added to the top and bottom sides or left and right sides
(depending on the
ListContainer orientation) outside of the visible area. |
void |
setFooterBoundarySwitch(boolean footerBoundaryEnabled) |
Sets whether to enable boundary drawing for footer components.
|
void |
setHeaderBoundarySwitch(boolean headerBoundaryEnabled) |
Sets whether to enable boundary drawing for header components.
|
void |
setItemClickedListener(ListContainer.ItemClickedListener listener) |
Sets a click listener for a component item.
|
void |
setItemLongClickedListener(ListContainer.ItemLongClickedListener listener) |
Sets a long-click listener for a component item.
|
void |
setItemProvider(BaseItemProvider itemProvider) |
Sets a
BaseItemProvider object to provide a ListContainer object
with components to display. |
void |
setItemSelectedListener(ListContainer.ItemSelectedListener listener) |
Sets a selected listener for a component item.
|
void |
setLayoutManager(LayoutManager layoutManager) |
Sets a
LayoutManager instance, which is used to lay out relevant child components. |
void |
setOrientation(int orientation) |
Sets an orientation of a layout.
|
void |
setReboundEffect(boolean enabled) |
Sets whether to enable the rebound effect.
|
void |
setReboundEffectParams(int overscrollPercent,
float overscrollRate,
int remainVisiblePercent) |
Configure rebound effect parameters.
|
void |
setReboundEffectParams(ListContainer.ReboundEffectParams reboundEffectParams) |
Sets rebound effect parameters.
|
void |
setScrollListener(ListContainer.ScrollListener listener) |
Sets a listener to monitor the end of scrolling of a
ListContainer object. |
void |
setSelectedItemIndex(int index) |
Selects a component item based on the input
position. |
void |
setShaderColor(Color color) |
Sets the shader color for this
ListContainer object. |
void |
setTextFilter(String filterText) |
Sets the text filter.
|
addDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findFocus, findNextFocusableComponent, findRequestNextFocus, getAccessibility, getAccessibilityDescription, getAlpha, getAltitude, getBackgroundElement, getBaseLine, getBottom, getBoundaryFadeEffectBottomRate, getBoundaryFadeEffectLeftRate, getBoundaryFadeEffectRightRate, getBoundaryFadeEffectTopRate, getCenterZoomFactor, getCentralScrollMode, getClickedListener, getClipEnabled, getComponentDescription, getComponentMinSize, getComponentParent, getComponentPosition, getComponentSize, getComponentStateChangedListener, getComponentTreeObserver, getContentEnable, getContentPosition, getContentPositionX, getContentPositionY, getContext, getContour, getContourRefreshedListener, getCornerMark, getDragAcceptAngle, getDraggedListener, getEditEventListener, getEstimatedHeight, getEstimatedWidth, getFadeEffectBoundaryWidth, getFadeEffectColor, getFocusable, getFocusBorderEnable, getFocusBorderPadding, getFocusBorderRadius, getFocusBorderWidth, getForegroundElement, getForegroundGravity, getForwardHoverListener, getForwardTouchListener, getGesturePriority, getHeight, getHorizontalPadding, getHorizontalPosition, getHoverEventListener, getId, getKeyEventListener, getLayoutConfig, getLayoutDirection, getLayoutDirectionResolved, getLayoutRefreshedListener, getLeft, getLocationOnScreen, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, getMatrix, getMinHeight, getMinWidth, getMode, getModeResolved, getMouseEventListener, getMousePointerStyleListener, getName, getPadding, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPivot, getPivotX, getPivotY, getResourceManager, getRight, getRotation, getRotationEventListener, getRotationSensitivity, getScale, getScaledListener, getScaleX, getScaleY, getScrollbarBackgroundColor, getScrollbarColor, getScrollbarFadingDelay, getScrollbarFadingDuration, getScrollBarMode, getScrollbarRadius, getScrollbarRoundRect, getScrollbarStartAngle, getScrollbarSweepAngle, getScrollbarThickness, getScrollState, getScrollValue, getSelfVisibleRect, getShadowColor, getSpeechEventListener, getTag, getTop, getTouchEventListener, getTransitionSymbol, getTranslation, getTranslationX, getTranslationY, getTranslationZ, getUserNextFocus, getVerticalPadding, getVerticalPosition, getVisibility, getVisibleRectOnScreen, getWidth, getWindowVisibleRect, hasFocus, hasFocusedEffect, hasOverlaps, hideFocusBorder, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onRestoreState, onRtlChanged, onSaveState, performScale, playSound, postLayout, refreshContour, release, removeBindStateChangedListener, removeScrolledListener, requestFocus, requestForceForwardTouchEvent, restoreComponentTreeState, saveComponentTreeState, scrollBy, scrollTo, setAccessibility, setAccessibilityDescription, setAlpha, setAltitude, setBackground, setBindStateChangedListener, setBottom, setBoundaryFadeEffectEnable, setCanAcceptScrollListener, setCenterZoomFactor, setCentralScrollMode, setClickable, setClickedListener, setClipEnabled, setClipToContourEnabled, setComponentDescription, setComponentMinSize, setComponentPosition, setComponentPosition, setComponentSize, setComponentStateChangedListener, setContentEnable, setContentPosition, setContentPositionX, setContentPositionY, setContour, setContourRefreshedListener, setDoubleClickedListener, setDragAcceptAngle, setDraggedListener, setEditEventListener, setEnabled, setEstimatedSize, setEstimateSizeListener, setFadeEffectBoundaryWidth, setFadeEffectColor, setFocusable, setFocusBorderEnable, setFocusBorderPadding, setFocusBorderRadius, setFocusBorderRadius, setFocusBorderWidth, setFocusChangedListener, setFocusedEffect, setForeground, setForegroundGravity, setForwardHoverListener, setForwardTouchListener, setGesturePriority, setHeight, setHorizontalPadding, setHorizontalPosition, setHoverEventListener, setId, setKeyEventListener, setLayoutConfig, setLayoutDirection, setLayoutRefreshedListener, setLeft, setLongClickable, setLongClickedListener, setMarginBottom, setMarginLeft, setMarginRight, setMarginsLeftAndRight, setMarginsTopAndBottom, setMarginTop, setMinHeight, setMinWidth, setMode, setMouseEventListener, setMousePointerStyleListener, setName, setOnDragListener, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRelative, setPaddingRight, setPaddingTop, setPivot, setPivot, setPivotX, setPivotY, setPosition, setPositionX, setPositionY, setPressState, setRight, setRotation, setRotationEventListener, setRotationSensitivity, setScale, setScaledListener, setScaleX, setScaleY, setScrollbarBackgroundColor, setScrollbarColor, setScrollbarFadingDelay, setScrollbarFadingDuration, setScrollbarFadingEnabled, setScrollBarMode, setScrollbarOverlapEnabled, setScrollbarRadius, setScrollbarRoundRect, setScrollbarStartAngle, setScrollbarSweepAngle, setScrollbarThickness, setScrolledListener, setSelected, setShadowColor, setShadowStyle, setSoundEnable, setSpeechEventListener, setTag, setTop, setTouchEventListener, setTouchFocusable, setTransitionSymbol, setTranslation, setTranslationX, setTranslationY, setTranslationZ, setUnconsumedKeyEventListener, setUserNextFocus, setVerticalPadding, setVerticalPosition, setVibrationEffectEnabled, setVisibility, setWidth, showFocusBorder, simulateClick, simulateDrag, startDragAndDrop, subscribeVoiceEvents, unsubscribeVoiceEventscreateLayoutConfig, dispatchRestoreState, dispatchSaveState, findComponentHolderById, getAutoLayout, getChildIndex, getComponentTransition, getFocusOrder, getLayoutManager, informConfigurationChanged, isClipToChildBoundsEnabled, isClipToPaddingBoundsEnabled, isTouchEventSplitable, onDrag, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setTouchEventSplitable, verifyLayoutConfiggetComponentParent, postLayoutpublic static final int INVALID_INDEX
An index is valid only when its index is an integer ranging from 0 to the total number of component items.
public static final float ROTATION_SENSITIVITY_DEFAULT
ListContainer to respond to rotating crown events.
You can use Component.setRotationSensitivity(float) to set.public static final float ROTATION_SENSITIVITY_HIGH
ListContainer to respond to rotating crown events.
You can use Component.setRotationSensitivity(float) to set.public static final float ROTATION_SENSITIVITY_LOW
ListContainer to respond to rotating crown events.
You can use Component.setRotationSensitivity(float) to set.public ListContainer(Context context)
ListContainer instance by using the default attribute set and style.context - Indicates the application context.public ListContainer(Context context, AttrSet attrSet)
ListContainer instance by using specified attribute set and default style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public ListContainer(Context context, AttrSet attrSet, String styleName)
ListContainer instance by using specified attribute set and specified
style after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public void setLayoutManager(LayoutManager layoutManager)
ComponentContainerLayoutManager instance, which is used to lay out relevant child components.setLayoutManager 在类中 ComponentContainerlayoutManager - Indicates the layout manager to set.public void onTextUpdated(String text, int start, int before, int count)
This method is used to process the changed text, for example, to verify the input LOV
to get LOVE, for which text is LOVE, start is 3, before is 3,
and count is 1.
onTextUpdated 在接口中 Text.TextObservertext - Indicates the current text.start - Indicates the start position of the text to be added.before - Indicates the length of the old text.count - Indicates the length of the text to be added.public void scrollTo(int position)
position - Indicates the position index of the specified component item.public void setContentStartOffSet(int startOffset)
startOffset - Indicates the start offset to set.public void setContentEndOffSet(int endOffset)
endOffset - Indicates the end offset to set.public void setContentOffSet(int startOffset,
int endOffset)
startOffset - Indicates the start offset to set.endOffset - Indicates the end offset to set.public int getContentStartOffset()
public int getContentEndOffset()
public void scrollToCenter(int position)
position - Indicates the position index of the specified component item.public void setItemClickedListener(ListContainer.ItemClickedListener listener)
This method inherits from ItemClickedListener and is called to process click events of a
component item.
listener - Indicates the click listener.public boolean executeItemClick(Component component, int position, long id)
This method is valid only when a click listener is set for the component item.
component - Indicates the clicked component item.position - Indicates the position of the clicked component item.id - Indicates the row ID of the clicked component item.true if the click listener is set and the click event is processed;
returns false otherwise.public void setItemLongClickedListener(ListContainer.ItemLongClickedListener listener)
This method inherits from ItemLongClickedListener and is called to process long-click
events of a component item.
listener - Indicates the long-click listener.protected boolean onItemLongClicked(ListContainer parent, Component component, int position, long id)
This method is called to process long-click events of a component item.
parent - Indicates the ListContainer object.component - Indicates the long-clicked component item.position - Indicates the position of the long-clicked component item.id - Indicates the row ID of the long-clicked component item.true if the long-clicked event is processed; returns false otherwise.public void setScrollListener(ListContainer.ScrollListener listener)
ListContainer object.listener - Indicates a ListContainer.ScrollListener object, representing the listener to set.public void setItemSelectedListener(ListContainer.ItemSelectedListener listener)
This method inherits from ItemSelectedListener and is called to process selected events
of a component item.
listener - Indicated the selected listener.protected void onItemSelected(ListContainer parent, Component component, int position, long id)
ListContainer object is selected.parent - Indicates the ListContainer object.component - Indicates the selected component item.position - Indicates the position of the selected component item.id - Indicates the row ID of the selected component item.public <T extends Component> T findComponentById(int id)
If the ID of the current component itself matches the given ID, the current component is returned. Otherwise,
null is returned.
findComponentById 在类中 ComponentContainerid - Indicates a unique identifier of a component.null if no component is found.public void addComponent(Component childComponent)
ComponentContainer.addComponent(ohos.agp.components.Component,int index) internally.addComponent 在类中 ComponentContainerchildComponent - Indicates the child component to add.UnsupportedOperationException - Method is not allowed in ListContainer.public void addComponent(Component childComponent, int width, int height)
addComponent 在类中 ComponentContainerchildComponent - Indicates the child component to add.width - Indicates the width of the child component, in pixels.height - Indicates the height of the child component, in pixels.UnsupportedOperationException - Method is not allowed in ListContainer.public void addComponent(Component childComponent, ComponentContainer.LayoutConfig layoutConfig)
addComponent 在类中 ComponentContainerchildComponent - Indicates the child component to add.layoutConfig - Indicates the layout parameters of the child component.UnsupportedOperationException - Method is not allowed in ListContainer.public void addComponent(Component childComponent, int index, ComponentContainer.LayoutConfig layoutConfig)
addComponent 在类中 ComponentContainerchildComponent - Indicates the child component to add.index - Indicates where to add the child component. The value -1 means to add the child
component to the end of the queue.layoutConfig - Indicates the layout parameters of the child component.UnsupportedOperationException - Method is not allowed in ListContainer.public void addComponent(Component childComponent, int index)
If no layout parameters are set for this child component, the default layout parameters of
ComponentContainer are used.
addComponent 在类中 ComponentContainerchildComponent - Indicates the child component to add.index - Indicates where to add the child component. The value -1 means to add the
component to the end. If a number greater than the value of getChildCount() is
provided, a runtime exception is returned.UnsupportedOperationException - Method is not allowed in ListContainer.public void removeComponent(Component component)
removeComponent 在接口中 ComponentParentremoveComponent 在类中 ComponentContainercomponent - Indicates the child component to remove.UnsupportedOperationException - Method is not allowed in ListContainer.public void removeComponentAt(int index)
removeComponentAt 在接口中 ComponentParentremoveComponentAt 在类中 ComponentContainerindex - Indicates the position index of the component to remove.UnsupportedOperationException - Method is not allowed in ListContainer.public void removeComponentById(int id)
removeComponentById 在类中 ComponentContainerid - Indicates the component ID.UnsupportedOperationException - Method is not allowed in ListContainer.public void removeComponents(int start,
int count)
removeComponents 在接口中 ComponentParentremoveComponents 在类中 ComponentContainerstart - Indicates the position index of the first removed component.count - Indicates the quantity of components to remove.UnsupportedOperationException - Method is not allowed in ListContainer.public void removeAllComponents()
ComponentContainer.removeAllComponents 在类中 ComponentContainerUnsupportedOperationException - Method is not allowed in ListContainer.public int getChildCount()
setItemProvider(ohos.agp.components.BaseItemProvider).getChildCount 在类中 ComponentContainerpublic Component getComponentAt(int position)
null is returned.
To check if obtained before component is removed from the set of visible items
ItemVisibilityChangedListener can be used.
getComponentAt 在类中 ComponentContainerposition - Indicates the index of child components.public void setExtraItemsNumber(int number)
ListContainer orientation) outside of the visible area.
The default value is 0.number - Indicates the number of extra items.IllegalArgumentException - Throws this exception if number is negative.public int getExtraItemsNumber()
ListContainer orientation) outside of the visible area.public void addItemVisibilityChangedListener(ListContainer.ItemVisibilityChangedListener listener)
ItemVisibilityChangedListener to the list of listeners.listener - Indicates the ItemVisibilityChangedListener.public void removeItemVisibilityChangedListener(ListContainer.ItemVisibilityChangedListener listener)
ItemVisibilityChangedListener from the list of listeners.listener - Indicates the ItemVisibilityChangedListener.public int getIndexForComponent(Component component)
Component item in a ListContainer object.component - Indicates the BaseItemProvider item matching the Component item.Component item in the ListContainer object;
returns INVALID_INDEX if the Component item is invisible or is not included in the ListContainer
object.@Deprecated public int getLastVisibleItemPosition()
getItemPosByVisibleIndex(int)
while passing the value equaling getVisibleIndexCount() minus 1.@Deprecated public int getFirstVisibleItemPosition()
getItemPosByVisibleIndex(int)public int getItemPosByVisibleIndex(int index)
index - Indicates the index of the visible item.public int getVisibleIndexCount()
public int getCenterFocusablePosition()
-1 if it does not exist.public void setReboundEffect(boolean enabled)
enabled - Specifies whether to enable the rebound effect. true indicates to enable the rebound
effect; false indicates to disable the rebound effect.public boolean getReboundEffect()
true if the rebound effect is enabled; returns false otherwise.public void setShaderColor(Color color)
ListContainer object.color - Indicates the shader color to set.getShaderColor()public Color getShaderColor()
ListContainer object.setShaderColor(Color)public void setOrientation(int orientation)
orientation - An orientation that will be used for layout.
Component#HORIZONTAL or Component#VERTICAL are applicable.getOrientation()public void setBoundary(Element boundary)
Element boundary that will be drawn between items in the list.boundary - Indicates the Element object to be used as the custom boundary.
null indicates that the default boundary is to be used.public Element getBoundary()
Element object used as the custom boundary of the list.Element object.public void setFooterBoundarySwitch(boolean footerBoundaryEnabled)
footerBoundaryEnabled - Specifies whether to enable boundary drawing for footer components.
true indicates to enable boundary drawing,
and false indicates the opposite case.public boolean getFooterBoundarySwitch()
true if boundary drawing is enabled;
returns false otherwise.public void setHeaderBoundarySwitch(boolean headerBoundaryEnabled)
headerBoundaryEnabled - Specifies whether to enable boundary drawing for header components.
true indicates to enable boundary drawing,
and false indicates the opposite case.public boolean getHeaderBoundarySwitch()
true if boundary drawing is enabled;
returns false otherwise.public void setBoundarySwitch(boolean boundaryEnabled)
boundaryEnabled - Specifies whether to enable boundary drawing for components.
true indicates to enable boundary drawing,
and false indicates the opposite case.public boolean getBoundarySwitch()
true if boundary drawing is enabled;
returns false otherwise.public void setBoundaryColor(Color color)
ListContainer object.color - Indicates the boundary color to set.getBoundaryColor()public Color getBoundaryColor()
ListContainer object.setBoundaryColor(Color)public void setBoundaryThickness(int thickness)
thickness - Indicates the boundary thickness, in pixels.public int getBoundaryThickness()
public void setSelectedItemIndex(int index)
position.index - Indicates the position of the component item to select, which is a non-negative integer.public int getSelectedItemIndex()
INVALID_INDEX
if no component item is selected.public void setTextFilter(String filterText)
filterText - Indicates the text filter to use.public String getTextFilter()
public BaseItemProvider getItemProvider()
BaseItemProvider object associated with a ListContainer object.BaseItemProvider object.public void setItemProvider(BaseItemProvider itemProvider)
BaseItemProvider object to provide a ListContainer object
with components to display.itemProvider - Indicates the BaseItemProvider object.public int getOrientation()
setOrientation(int)public void setReboundEffectParams(int overscrollPercent,
float overscrollRate,
int remainVisiblePercent)
overscrollPercent - Indicates the overscroll percent (default value: 40). If the percent of
scrolled content exceeds the value of this parameter, the content scrolling speed is affected by the
overscrollRate parameter. Specifically, if the value of overscrollRate is less than
1.0, your finger moves faster than the content.overscrollRate - Indicates the overscroll rate (default value: 0.6). This parameter affects the
content scrolling speed if the percent of scrolled content exceeds the value of the
overscrollPercent parameter. Specifically, the content scrolling speed is equal to the finger
scrolling speed multiplied by the value of overscrollRate.remainVisiblePercent - Indicates the minimum percent of scrollable content that should remain visible
during overscrolling. The default value is 20.IllegalArgumentException - if at least one of the following conditions is true:
(1) overscrollPercent is not in range [0, 100] (2) overscrollRate <= 0
(3) remainVisiblePercent is not in range [0, 100]public void setReboundEffectParams(ListContainer.ReboundEffectParams reboundEffectParams)
reboundEffectParams - Indicates a ReboundEffectParams object holding the rebound effect parameters.IllegalArgumentException - if reboundEffectParams is null or contains invalid value.getReboundEffectParams(),
setReboundEffectParams(int, float, int)public ListContainer.ReboundEffectParams getReboundEffectParams()
ReboundEffectParams object.ReboundEffectParams object holding the rebound parameters.setReboundEffectParams(ReboundEffectParams),
setReboundEffectParams(int, float, int)public void moveChildToFront(Component component)
moveChildToFront 在接口中 ComponentParentmoveChildToFront 在类中 ComponentContainercomponent - Indicates the component to bring to the front.