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

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

HarmonyOS
2024-05-26 15:42:04
9641浏览
收藏 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 
      } 
    }) 
  } 
} 
}
  • 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.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
分享
微博
QQ
微信
回复
2024-05-27 20:44:43


相关问题
图片编辑-如何添加多个贴纸功能
628浏览 • 0回复 待解决
HarmonyOS 添加通讯录功能
610浏览 • 1回复 待解决
HarmonyOS元服务添加、删除功能
1387浏览 • 1回复 待解决
PolarDB如何手动添加limit分页功能?
2975浏览 • 1回复 待解决
版本新增taskpool的相关功能验证
1402浏览 • 1回复 待解决
HarmonyOS 如何实现图片编辑功能
622浏览 • 1回复 待解决
HarmonyOS 图片保存功能
579浏览 • 1回复 待解决
如何在HarmonyOS中实现图片上传功能
800浏览 • 0回复 待解决
怎么实现保存网络图片到相册功能
1215浏览 • 1回复 待解决
想要实现一个图片裁剪的功能
907浏览 • 1回复 待解决
HarmonyOS 选择图片,裁剪的功能
576浏览 • 1回复 待解决
HarmonyOS 实现RSA加密功能
817浏览 • 1回复 待解决