首页 > 解决方案 > 手势不适用于 Android 上的 ListView 项目

问题描述

我想对 FireMonkey 多设备应用程序中的项目使用“LongTap”和“PressAndTap”手势,TListView设置了如下OnGesture事件:ListView

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

 Handled := True;
end;

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

我已经在InteractiveGestures财产上检查了我想要的手势

我已经测试过有或没有GestureManager

如何为 Listview 的项目设置 OnGesture?

没有任何类似OnGestureforTListViewItem类型的事件

我正在使用 Delphi 10.2.3 Tokyo

标签: androidlistviewdelphifiremonkeygesture

解决方案


我按照 Tom 提供的链接中的说明测试了一个应用程序,您需要在 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;

推荐阅读