拖动添加图片功能,软件添加功能图标,实现新增功能

软件添加功能图标,实现新增功能

HarmonyOS
2024-05-26 15:42:04
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

使用的核心API

GridObjectSortComponent

核心代码解释

核心代码如下:

import { GridObjectSortComponent, GridObjectSortComponentItem, GridObjectSortComponentOptions, GridObjectSortComponentType } from '@ohos.arkui.advanced.GridObjectSortComponent' 
@Entry 
@Component 
struct Index { 
@State dataList: GridObjectSortComponentItem[] = [ 
  { 
    id: 0, 
    url: $r('app.media.icon'), 
    text: '位置信息', 
    selected: true, 
    order: 3 
  }, 
  { 
    id: 1, 
    url: $r('app.media.icon'), 
    text: '移动数据', 
    selected: true, 
    order: 9 
  }, 
  { 
    id: 2, 
    url: $r('app.media.icon'), 
    text: 'NFC', 
    selected: false, 
    order: 1 
  }, 
  { 
    id: 3, 
    url: $r('app.media.icon'), 
    text: '响铃关闭', 
    selected: true, 
    order: 4 
  }, 
  { 
    id: 4, 
    url: $r('app.media.icon'), 
    text: '响铃', 
    selected: false, 
    order: 5 
  }, 
  { 
    id: 5, 
    url: $r('app.media.icon'), 
    text: '低电量模式', 
    selected: true, 
    order: 6 
  }, 
  { 
    id: 6, 
    url: $r('app.media.icon'), 
    text: '截屏', 
    selected: true, 
    order: 7 
  }, 
  { 
    id: 7, 
    url: $r('app.media.icon'), 
    text: '屏幕录制', 
    selected: true, 
    order: 8 
  }, 
  { 
    id: 8, 
    url: $r('app.media.icon'), 
    text: '超级省电', 
    selected: false, 
    order: 9 
  }, 
] 
​ 
@State option: GridObjectSortComponentOptions = { 
  type: GridObjectSortComponentType.IMAGE_TEXT, 
  imageSize: 45, 
  normalTitle: '菜单', 
  editTitle: '编辑', 
  showAreaTitle: '长按拖动排序', 
  addAreaTitle: '点击添加' 
} 
​ 
build() { 
  Column() { 
    GridObjectSortComponent({ 
      options: this.option, 
      dataList: this.dataList, 
      onSave: ( 
        select: Array<GridObjectSortComponentItem>, 
        unselect: Array<GridObjectSortComponentItem> 
      ) => { 
        // save ToDo 
      }, 
      onCancel: () =>{ 
        // cancel ToDo 
      } 
    }) 
  } 
} 
}
分享
微博
QQ
微信
回复
2024-05-27 20:44:43
相关问题
PolarDB如何手动添加limit分页功能?
1197浏览 • 1回复 待解决
版本新增taskpool的相关功能验证
365浏览 • 1回复 待解决
zxing能否支持添加中心图标
475浏览 • 1回复 待解决
grid如何怎么实现拖拽功能
334浏览 • 1回复 待解决
SoundPool实现音频播放功能
559浏览 • 1回复 待解决
定时提醒功能如何实现?
3411浏览 • 1回复 待解决
鸿蒙如何实现分享功能
16105浏览 • 2回复 待解决
Martix实现倾斜的功能
389浏览 • 1回复 待解决
Grid如何实现拖拽功能
891浏览 • 1回复 待解决
如何实现媒体会话交互功能
243浏览 • 1回复 待解决
【JS】如何实现左滑删除功能
1988浏览 • 1回复 待解决
webview如何实现网络请求拦截功能
619浏览 • 1回复 待解决
求大佬告知如何实现复制功能
560浏览 • 1回复 待解决
如何实现双路预览+录制功能
452浏览 • 1回复 待解决
RichEditor添加、删除、重载图片
362浏览 • 1回复 待解决
如何给按钮添加图片
944浏览 • 3回复 待解决
如何实现向用户申请授权的功能
535浏览 • 1回复 待解决
实现弹幕功能的三方库
528浏览 • 1回复 待解决
如何实现 app 内置全局悬浮球功能
555浏览 • 1回复 待解决