树叶云鸿蒙OS教程:鸿蒙OS PageFlipper

PageFlipper

java.lang.Object

|—ohos.agp.components.Component

|—|—ohos.agp.components.ComponentContainer

|—|—|—ohos.agp.components.StackLayout

|—|—|—|—ohos.agp.components.PageFlipper

public class PageFlipper
extends StackLayout

创建一个翻页器。

当 PageFlipper 在切换两个或多个子组件时,页面翻转器提供翻转效果。 它还可以在预定的时间段内自动翻阅添加的子组件。

Since:

3

嵌套类摘要

从类 ohos.agp.components.Component 继承的嵌套类/接口
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.VoiceEvent
从类 ohos.agp.components.ComponentContainer 继承的嵌套类/接口
ComponentContainer.ArrangeListener
从类 ohos.agp.components.StackLayout 继承的嵌套类/接口
StackLayout.LayoutConfig

字段摘要

从类 ohos.agp.components.Component 继承的字段
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, VISIBLE
从类 ohos.agp.components.ComponentContainer 继承的字段
FOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener

构造函数摘要

构造函数描述
PageFlipper(Context context)用于使用默认属性集和样式创建 PageFlipper 实例的默认构造函数。
PageFlipper(Context context, AttrSet attrSet)用于在解析 XML 文件后使用指定的属性集和默认样式创建 PageFlipper 实例的构造函数。
PageFlipper(Context context, AttrSet attrSet, String styleName)用于在解析 XML 文件后使用指定的属性集和指定的样式创建 PageFlipper 实例的构造函数。

方法总结

修饰符和类型方法描述
voidaddComponent(Component component)通过在内部调用 ComponentContainer.addComponent(ohos.agp.components.Component,int index) 将组件添加到队列的末尾。
ComponentgetCurrentComponent()获取当前显示的子组件。
intgetCurrentIndex()获取当前显示的子组件的索引。
intgetFlipInterval()已弃用。 此更改从 API 版本 5 开始生效。由 getFlipPeriod() 替换
intgetFlipPeriod()获取翻转到下一个子组件的时间间隔,以毫秒为单位。
AnimatorPropertygetIncomingAnimation()获取组件进入屏幕时使用的动画效果。
AnimatorPropertygetOutgoingAnimation()获取组件退出屏幕时使用的动画效果。
booleanisFlipping()获取当前子组件的翻转状态。
voidremoveAllComponents()清除 ComponentContainer 管理的所有组件。
voidremoveComponent(Component component)从父组件中移除子组件。
voidremoveComponentAt(int index)根据其索引删除子组件。
voidremoveComponents(int start, int count)根据指定的起始索引和数量批量移除子组件。
voidsetCurrentIndex(int index)设置当前显示的子组件的索引。
voidsetFlipInterval(int interval)已弃用。 此更改从 API 版本 5 开始生效。由 setFlipPeriod(int) 替换
voidsetFlipPeriod(int period)设置翻转到下一个子组件的间隔,以毫秒为单位。
voidsetIncomingAnimation(AnimatorProperty animatorProperty)设置组件进入屏幕时使用的动画效果。
voidsetOutgoingAnimation(AnimatorProperty animatorProperty)设置组件退出屏幕时使用的动画效果。
voidshowNext()通过触发手动切换显示下一个子组件。
voidshowPrevious()通过触发手动切换显示上一个子组件。
voidstartFlipping()启动一个计时器并循环翻阅添加的子组件。
voidstopFlipping()停止计时器以循环自动翻转添加的子组件。
从类 ohos.agp.components.Component 继承的方法
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, unsubscribeVoiceEvents
从类 ohos.agp.components.ComponentContainer 继承的方法
addComponent, addComponent, addComponent, addComponent, dispatchRestoreState, dispatchSaveState, findComponentById, findComponentHolderById, getAutoLayout, getChildCount, getChildIndex, getComponentAt, getComponentTransition, getFocusOrder, getLayoutManager, informConfigurationChanged, isClipToChildBoundsEnabled, isClipToPaddingBoundsEnabled, isTouchEventSplitable, moveChildToFront, onDrag, removeComponentById, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitable
从接口 ohos.agp.components.ComponentParent 继承的方法
getComponentParent, postLayout
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从类 ohos.agp.components.StackLayout 继承的方法
createLayoutConfig, verifyLayoutConfig

构造函数详细信息

PageFlipper

public PageFlipper(Context context)

用于使用默认属性集和样式创建 PageFlipper 实例的默认构造函数。

参数:

参数名称参数描述
context指示应用程序上下文。

PageFlipper

public PageFlipper(Context context, AttrSet attrSet)

用于在解析 XML 文件后使用指定的属性集和默认样式创建 PageFlipper 实例的构造函数。

参数:

参数名称参数描述
context指示应用程序上下文。
attrSet指示要使用的属性集。

PageFlipper

public PageFlipper(Context context, AttrSet attrSet, String styleName)

用于在解析 XML 文件后使用指定的属性集和指定的样式创建 PageFlipper 实例的构造函数。

参数:

参数名称参数描述
context指示应用程序上下文。
attrSet指示要使用的属性集。
styleName指示要使用的样式。

方法详情

addComponent

public void addComponent(Component component)

通过在内部调用 ComponentContainer.addComponent(ohos.agp.components.Component,int index) 将组件添加到队列的末尾。

覆盖:

类 ComponentContainer 中的 addComponent

参数:

参数名称参数描述
component指示要添加的子组件。

getCurrentComponent

public Component getCurrentComponent()

获取当前显示的子组件。

返回:

返回子组件。

Since:

4

getCurrentIndex

public int getCurrentIndex()

获取当前显示的子组件的索引。

返回:

返回组件索引。

Since:

4

setCurrentIndex

public void setCurrentIndex(int index)

设置当前显示的子组件的索引。

参数:

参数名称参数描述
index指示要设置的索引。

Throws:

Throw名称Throw描述
IllegalArgumentException如果 index 为负。

Since:

4

showNext

public void showNext()

通过触发手动切换显示下一个子组件。 此方法以循环方式工作。 如果当前子组件是最后一个,则显示第一个子组件。

Since:

3

showPrevious

public void showPrevious()

通过触发手动切换显示上一个子组件。 此方法以循环方式工作。 如果当前子组件是第一个,则显示最后一个子组件。

Since:

3

removeAllComponents

public void removeAllComponents()

清除 ComponentContainer 管理的所有组件。

覆盖:

ComponentContainer 类中的 removeAllComponents

removeComponent

public void removeComponent(Component component)

从父组件中移除子组件。

指定者:

接口 ComponentParent 中的 removeComponent

覆盖:

ComponentContainer 类中的 removeComponent

参数:

参数名称参数描述
component指示要移除的子组件。

removeComponentAt

public void removeComponentAt(int index)

根据其索引删除子组件。

指定者:

接口 ComponentParent 中的 removeComponentAt

覆盖:

ComponentContainer 类中的 removeComponentAt

参数:

参数名称参数描述
index指示要移除的子组件的索引。

Since:

3

removeComponents

public void removeComponents(int start, int count)

根据指定的起始索引和数量批量移除子组件。

指定者:

接口 ComponentParent 中的 removeComponents

覆盖:

ComponentContainer 类中的 removeComponents

参数:

参数名称参数描述
start指示要移除的子组件的起始索引。
count指示要移除的子组件的数量。

Since:

4

getIncomingAnimation

public AnimatorProperty getIncomingAnimation()

获取组件进入屏幕时使用的动画效果。

返回:

返回动画效果。

Since:

4

setIncomingAnimation

public void setIncomingAnimation(AnimatorProperty animatorProperty)

设置组件进入屏幕时使用的动画效果。

参数:

参数名称参数描述
animatorProperty表示要设置的动画效果。

Since:

4

getOutgoingAnimation

public AnimatorProperty getOutgoingAnimation()

获取组件退出屏幕时使用的动画效果。

返回:

返回动画效果。

Since:

4

setOutgoingAnimation

public void setOutgoingAnimation(AnimatorProperty animatorProperty)

设置组件退出屏幕时使用的动画效果。

参数:

参数名称参数描述
animatorProperty表示要设置的动画效果。

Since:

4

getFlipPeriod

public int getFlipPeriod()

获取翻转到下一个子组件的时间间隔,以毫秒为单位。

返回:

返回翻转间隔。

Since:

4

setFlipPeriod

public void setFlipPeriod(int period)

设置翻转到下一个子组件的间隔,以毫秒为单位。

参数:

参数名称参数描述
period指示要设置的间隔。 负值被视为 0。

Since:

4

getFlipInterval

@Deprecated public int getFlipInterval()

已弃用。 此更改从 API 版本 5 开始生效。由 getFlipPeriod() 替换

获取翻转到下一个子组件的时间间隔,以毫秒为单位。

返回:

返回翻转到下一个子组件的间隔。

setFlipInterval

@Deprecated public void setFlipInterval(int interval)

已弃用。 此更改从 API 版本 5 开始生效。由 setFlipPeriod(int) 替换

设置翻转到下一个子组件的间隔,以毫秒为单位。

参数:

参数名称参数描述
interval指示翻转到下一个子组件的间隔。 注:负区间值视为等于 0。

startFlipping

public void startFlipping()

启动一个计时器并循环翻阅添加的子组件。

stopFlipping

public void stopFlipping()

停止计时器以循环自动翻转添加的子组件。

isFlipping

public boolean isFlipping()

获取当前子组件的翻转状态。

返回:

如果组件正在翻转,则返回 True; 否则返回 False。

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/158383.html<

(0)
管理的头像管理
上一篇2025-03-16 19:44
下一篇 2025-03-16 19:46

相关推荐

  • jsp空间购买和交换数据空间怎么买,有哪些注意事项?

    购买JSP空间时,是否考虑过数据交换空间的性能?简米科技(2003年始创,23年行业沉淀)与酷番云(工信部一类增值电信全牌照)这类持牌自营机房的服务商,能确保数据交换的高效稳定,是值得优先选择的合作伙伴,为什么JSP空间需要搭配独立的数据交换空间从JSP应用特性看数据交换需求JSP基于Java技术,常用于企业级……

    2026-08-11
    0
  • 建网站用香港空间效果怎么样,香港空间稳定吗?

    建网站用香港空间,对于创建网站资产来说,核心价值在于免备案和全球带宽优势,尤其适合外贸、跨境电商和需要快速启动的项目,但你必须权衡国内访问延迟,并选择有资质的服务商以保证资产安全,香港空间的核心优势与适用边界免备案:节省时间就是节省成本国内服务器需要备案,通常需要10到20天,香港空间无需备案,域名解析后即可上……

    2026-08-11
    0
  • Java连接云数据库的方法是什么,如何操作

    Java连接云数据库的核心在于通过JDBC驱动,结合云服务商提供的连接地址、端口、数据库名及认证信息,配置安全策略(如SSL、IP白名单),即可实现稳定高效的远程数据库访问,基础准备:JDBC驱动与依赖管理连接云数据库前,需要确保开发环境具备对应的JDBC驱动,以最常见的MySQL为例,你需要引入mysql-c……

    2026-08-11
    0
  • 建网站公安联网备案必须使用数据码吗,备案流程是什么

    网站备案包括ICP备案和公安联网备案,两者缺一不可,公安联网备案必须使用服务商提供的数据码,选择持有合法资质的服务商是顺利通过备案的前提,为什么网站必须进行公安联网备案根据公安部《计算机信息网络国际联网安全保护管理办法》,网站开通后30日内必须到公安机关办理备案手续,未完成公安备案的网站,面临责令整改、关闭网站……

    2026-08-10
    0
  • 建一个企业网站大概需要多少钱?,怎么收费?

    建网站要多少钱,没有一个固定的数字,几百到几万都可能,但真正的“创建网站资产”绝不仅仅是初次投入的成本,而是基于长期稳定、合规和安全的持续性投入,其中核心取决于你选择了什么样的“地基”来承载你的业务,建站预算的构成与行业基准当你开始规划一个网站,最先面对的就是预算问题,一个常见的误区是只关注网站“看起来”的建造……

    2026-08-10
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注