【问题标题】:Gestures does not work for ListView Items on Android手势不适用于 Android 上的 ListView 项目
【发布时间】:2018-09-20 21:04:30
【问题描述】:

我想在 FireMonkey 多设备应用程序中对 TListViewitems 使用“LongTap”和“PressAndTap”手势,我已将 ListViewOnGesture 事件设置如下:

begin
 case EventInfo.GestureID of
  igiPressAndTap : begin
                    {...}
                   end;
  igiLongTap : begin
                {...}
               end;
 end;

 Handled := True;
end;

但是当我在 Android 设备上测试它时,OnGesture 事件没有发生

我已经在InteractiveGestures 属性上检查了我想要的手势

我测试过有没有GestureManager

如何为 Listview 的项目设置 OnGesture?

TListViewItem 类型没有像 OnGesture 这样的事件

我正在使用 Delphi 10.2.3 Tokyo

【问题讨论】:

  • 您是否按照this doc 中的说明设置手势,包括检查适用的InteractiveGestures
  • @TomBrunberg 是的,我做到了
  • 好的,那么您必须提供minimal reproducible example
  • @TomBrunberg,感谢您的帮助,但我认为一切都很清楚,创建一个新的多设备项目在表单上添加一个 TListView,设置 OnGesture 事件并设置 InteractiveGestures 检查,添加一些项目到 listview 运行-时间,这是我在问题帖子中解释的示例
  • 我们遇到了同样的问题。一个在 XE7 中开发并且运行良好的项目,现在针对 10.3.2 Rio,在 Android 设备上双击时不会触发手势。 InteractiveGestures 已填充。你解决了吗?

标签: android listview delphi firemonkey gesture


【解决方案1】:

我按照 Tom 提供的link 中的说明测试了一个应用程序,您需要在 Object Inspector 的 Touch 属性中设置所需的手势。

在 OnGesture 事件中,代码只检查 GestureID 是否是我要执行的手势。

procedure TfrmMain.listProdtsRotaGesture(Sender: TObject;
  const EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
  case EventInfo.GestureID of
    igiLongTap:
      ShowMessage('longTap: ' + listProdtsRota.Selected.Index.ToString);

    igiPressAndTap:
      ShowMessage('pressAndTap: ' + listProdtsRota.Selected.Index.ToString);

    igiDoubleTap:
      ShowMessage('doubleTap: ' + listProdtsRota.Selected.Index.ToString);
  end;
end;

【讨论】:

  • 谢谢,这些链接是使用手势的主要文档,我已经完成了所有操作,但没有成功。您在哪个设备上测试过?你确定它适用于列表视图的“项目”吗?
  • 我在一个Moto G5,Android 7.0上测试过,需要在列表视图的Touch属性中添加InteractiveGestures,而不是item,OnGesture事件也是来自列表视图,您可以使用listView.Selected 获取所选项目。我编辑了答案以显示这一点
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-23
  • 1970-01-01
  • 1970-01-01
  • 2013-12-01
  • 1970-01-01
相关资源
最近更新 更多