防止“清除” TListBox项

时间:2018-09-21 09:05:47

标签: delphi touch firemonkey tlistbox

我有一个Delphi Berlin构建的Android应用程序,其中包含一个TListBox。在某些时候,我手动添加了一个TListItem(下面的代码)。不幸的是,用户可以在其上向右或向左滑动,这似乎删除了列表项,并且此后的操作使应用程序崩溃。

如何禁用在TListBoxItem上向右或向左滑动的功能?我没有看到任何滑动以删除某种功能,并且我已经尝试捕获滑动右手势而没有运气。如果我将Selectable设置为false,则无法再滑动它,但是上面项目的绘画将被删除。

在运行时添加项目的代码:

procedure TMyForm.InfoButtonCLick(Sender: TObject)
var
 Item : TListBoxItem;
begin
  Item                  := TListBoxItem.Create(nil);
  Item.Text             := '';
  Item.Height           := 200; 
  Item.HitTest          := false;
  Item.Selectable       := false;

  // Other things I tried without success
  //    Item.Touch.InteractiveGestures := [];
  //    Item.DragMode         := TDragMode.dmManual;
  // tried to capture swite right and left and declare them as handled
  //    Item.OnGesture        := OnListItemGesture;    

  // lb_Files is the ListBox
  lb_Files.InsertObject(lb_Files.ItemIndex + 1, Item);
  lb_Files.ScrollToItem(Item);
end;

0 个答案:

没有答案
相关问题