HarmonyOS 筛选控件缺失

使用select或者CustomDialog并不能实现这个筛选功能,是否有能力实现该筛选功能?

HarmonyOS
2024-12-25 13:36:32
1553浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

参考示例:

import { ComponentContent, window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';

class Params {
  arr: number[] = []

  constructor(arr: number[]) {
    this.arr = arr;
  }
}

@Builder
function buildText(params: Params) {
  Column() {
    List({ space: 20, initialIndex: 0 }) {
      ForEach(params.arr, (item: number) => {
        ListItem() {
          Text('' + item)
            .width('100%')
            .height(100)
            .fontSize(16)
            .textAlign(TextAlign.Center)
            .borderRadius(10)
            .backgroundColor(0xFFFFFF)
        }
      }, (item: string) => item)
    }
    .listDirection(Axis.Vertical) // 排列方向
    .scrollBar(BarState.Off)
    .friction(0.6)
    .divider({
      strokeWidth: 2,
      color: 0xFFFFFF,
      startMargin: 20,
      endMargin: 20
    }) // 每行之间的分界线
    .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
    .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
      console.info('first' + firstIndex)
      console.info('last' + lastIndex)
      console.info('center' + centerIndex)
    })
    .onScroll((scrollOffset: number, scrollState: ScrollState) => {
      console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
    })
    .width('90%')
  }
  .width('100%')
  .height(500).backgroundColor(Color.Red)
  .padding({ top: 5 })
}

@Entry
@Component
struct Parent {
  arr: Array<number> = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  @State bgColor: string = '#FFFFFF'

  build() {
    Column() {
      Column() {
        Button("click").onClick(() => {
          let uiContext = this.getUIContext();
          let promptAction = uiContext.getPromptAction();
          let contentNode =
            new ComponentContent((uiContext as UIContext), wrapBuilder(buildText), new Params(this.arr));
          try {
            promptAction.openCustomDialog(contentNode, {
              isModal: false,
              onWillDismiss: () => {
                this.bgColor = '#FFFFFF'
                promptAction.closeCustomDialog(contentNode)
              }
            });
          } catch (error) {
            let message = (error as BusinessError).message;
            let code = (error as BusinessError).code;
            console.error(`OpenCustomDialog args error code is ${code}, message is ${message}`);
          }
          ;

          this.bgColor = '#50C4C0C0'
        })
      }

      Column() {
        Text("这是内容")
      }.width('100%').height(800).backgroundColor(this.bgColor)
    }
  }
}
  • 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.
分享
微博
QQ
微信
回复
2024-12-25 16:11:30


相关问题
HarmonyOS 需要一个筛选页面的demo
1101浏览 • 1回复 待解决
轻量系统应用开发汉字缺失
5091浏览 • 1回复 待解决
缺失getcontext函数导致breakpad编译失败
1655浏览 • 1回复 待解决
HarmonyOS UI布局子控件超出父控件宽度
863浏览 • 1回复 待解决
HarmonyOS 自定义时间控件和日期控件
1252浏览 • 1回复 待解决
HarmonyOS 短信校验控件
615浏览 • 1回复 待解决
HarmonyOS select控件高度
593浏览 • 1回复 待解决
HarmonyOS Tab控件咨询
738浏览 • 1回复 待解决
HarmonyOS 获取控件坐标
697浏览 • 1回复 待解决
HarmonyOS 安全控件使用
639浏览 • 1回复 待解决
HarmonyOS 刷新控件问题
921浏览 • 1回复 待解决
HarmonyOS saveButton控件问题
854浏览 • 1回复 待解决
HarmonyOS 如何设置控件样式?
839浏览 • 1回复 待解决
HarmonyOS Tabs控件fadingEdge问题
1342浏览 • 1回复 待解决