侧滑删除功能的列表有哪些?

侧滑删除功能的列表

HarmonyOS
2024-05-26 14:27:06
440浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
伊普洛先生

核心代码

@Entry 
@Component 
struct Page { 
  @State userSelect: Array<connection> = [ 
    new connection($r('app.media.icon'), '小明', '我还没出门'), 
    new connection($r('app.media.icon'), '李华', '早上下雨了')] 
  
  @Builder itemEnd(index: number) { 
    // 侧滑后尾端出现的组件 
    Button({ type: ButtonType.Circle }) { 
      Image($r('app.media.icon')) 
        .width(40) 
        .height(40) 
    }.height(60).backgroundColor(Color.White) 
    .onClick(() => { 
      this.userSelect.splice(index, 1); 
    }) 
  } 
  
  build() { 
    Row() { 
      Column() { 
        List() { 
          ForEach(this.userSelect, (item: connection,index:number) => { 
            ListItem() { 
              Row({ space: 10 }) { 
                Badge({ 
                  count: 1, 
                  position: BadgePosition.RightTop, 
                  style: { badgeSize: 20, badgeColor: '#FA2A2D' } 
                }){ 
                  Image(item.uImage).height(60).borderRadius(10) 
                } 
                Column() { 
                  Column() { 
                    Text(item.name).fontSize(22) 
                  }.width('100%').alignItems(HorizontalAlign.Start) 
  
                  Column() { 
                    Text(item.msg).fontColor('#D3D3D3') 
                  }.height(30).width('100%') 
                  .alignItems(HorizontalAlign.Start) 
                  .justifyContent(FlexAlign.End) 
                } 
                .width('70%') 
                // .backgroundColor(Color.Brown) 
              }.border({ width: { bottom: 1 }, color: '#C0C0C0' }) 
              .width('100%') 
              .height(80) 
              .padding({ left: 10 }) 
            }.swipeAction({ end: this.itemEnd(index) }) 
          }) 
        } 
      } 
      .width('100%') 
    } 
    .height('100%') 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.

适配的版本信息

  • IDE:DevEco Studio 4.0.3.600
  • SDK:HarmoneyOS 4.0.10.11
分享
微博
QQ
微信
回复
2024-05-27 18:15:27


相关问题
HarmonyOS RN删除组件
808浏览 • 1回复 待解决
【JS】如何实现左删除功能
4317浏览 • 1回复 待解决
HarmonyOS 事件
656浏览 • 1回复 待解决
查看文件列表方式哪些
1373浏览 • 1回复 待解决
HarmonyOS 怎么禁止
793浏览 • 1回复 待解决
HarmonyOS 关于返回监听
527浏览 • 1回复 待解决
HarmonyOS 退出问题
914浏览 • 1回复 待解决
HarmonyOS 如何禁止系统返回
514浏览 • 1回复 待解决
HarmonyOS ListItem菜单动态设置
858浏览 • 1回复 待解决
HarmonyOS 怎么让listitem按钮失效
567浏览 • 1回复 待解决
证书锁定功能示例哪些
1471浏览 • 1回复 待解决
HarmonyOS UIAbility 时如何拦截返回
685浏览 • 1回复 待解决