HarmonyOS ListScroller.closeAllSwipeActions的onFinish无效,不会触发

ListScroller.closeAllSwipeActions的onFinish无效,不会触发,可以提供示例代码吗

HarmonyOS
2025-01-09 15:41:24
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Heiang

可以参考如下demo:

@Entry
@Component
struct Test8 {
  listData = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
  scroller: ListScroller = new ListScroller();

  @Builder
  itemEnd() {
    Row() {
      Button("Delete").margin("4vp")
        .onClick(()=>{
          this.scroller.closeAllSwipeActions({
            onFinish: () => {
              console.debug('删除')
            }
          })
        })
      Button("Set").margin("4vp")
        .onClick(()=>{
          this.scroller.closeAllSwipeActions({
            onFinish: () => {
              console.debug('设置')
            }
          })
        })
    }.padding("4vp").justifyContent(FlexAlign.SpaceEvenly)
  }

  build() {
    Column() {
      List({ space: 10, scroller: this.scroller }) {
        ForEach(
          this.listData,
          (item: number, index: number) => {
            ListItem() {
              Column(){
                Text(`${item}`)
                  .height(80).width('100%').backgroundColor(Color.Blue)
              }
            }
            .swipeAction({
              end: {
                builder: () => {
                  this.itemEnd()
                }
              }
            , edgeEffect: SwipeEdgeEffect.Spring
            })
          },
          (item: number, index: number) => {
            return (item + index).toString()
          },
        )
      }
      .cachedCount(4)
      .margin({ top: 10 })
    }
  }
}
分享
微博
QQ
微信
回复
2025-01-09 17:16:26
相关问题
HarmonyOS @Watch无效
216浏览 • 1回复 待解决
HarmonyOS animateToduration无效
204浏览 • 1回复 待解决
CommonDialogsetSwipeToDismiss(false)无效
6759浏览 • 1回复 待解决
HarmonyOS designWidth设置无效
175浏览 • 1回复 待解决
HarmonyOS appRecovery.restartApp无效
614浏览 • 1回复 待解决
notifyDataChanged() 无效
6725浏览 • 4回复 待解决
HarmonyOS LazyForEach不会更新@State里
410浏览 • 1回复 待解决
HarmonyOS Token无效问题
249浏览 • 1回复 待解决