gpt4 book ai didi

android - 相当于 Ionic 2 中的 setOnItemLongClickListener

转载 作者:行者123 更新时间:2023-11-29 17:03:26 25 4
gpt4 key购买 nike

我创建了一个功能,当用户简单地点击该项目时,在点击项目的屏幕上显示 Toast,一个警告:

我的 .ts 文件中的函数:

itemSelected(item: string) {
this.toastCtrl.showToast("Selected Item: " + item, 'bottom');
}

按钮:

<button ion-item *ngFor="let item of people" (click)="itemSelected(item)">
{{ item.firstname }}
</button>

这正常工作,但是现在我想在用户长按该项目时创建一个选项列表。在 native Android 中,可以使用 setOnItemLongClickListener 方法执行此操作,但我不知道 Ionic 中的等效方法是什么?哪个方法等同于 Ionic 2 中的 setOnItemLongClickListener

最佳答案

您可以尝试 Ionic 2 手势提供的 press 事件。查看有关手势的文档 here.

<button ion-item *ngFor="let item of people" (press)="itemSelected(item)">
{{ item.firstname }}
</button>

关于android - 相当于 Ionic 2 中的 setOnItemLongClickListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42231885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com