滚动TListBox时滞后

时间:2013-10-18 19:22:00

标签: ios delphi listbox scroll delphi-xe5

我有一个TListBox,它包含大约50个TListboxItems,又名物品。每个项目包含3个TTexts用作标签,1个TImage,分辨率为48x48,表示“状态”,以及一个用于选择项目的复选框。在设备上时,滚动时存在很大的延迟时间。它通常是跳跃的,零星的,不一致的。

这是因为我的物品太多了吗?或者是因为它们包含TTexts,Timage等? 或者我可以采取哪些措施来平滑TListbox的滚动过程。

我正在使用Delphi xe5开发iOS应用程序。我确实确保检查TListbox的'sorted'属性是:= False;

更新(对Jerry Dodge的回应):

while XMLNode <> nil do begin
            Main_Form.LBoxEntries.Items.Add('');
            Item1:=Main_Form.LBoxEntries.ListItems[Main_Form.LBoxEntries.Items.Count-1];
            Item1.Height              := 80;
            Item1.Width               := ClientWidth;

          if XMLNode.ChildNodes['SCANSTATUS'].Text = '0' then begin
            Item1.ItemData.Bitmap := Main_Form.Red.Bitmap;
            Item1.Tag             := 0;
          end;
          if XMLNode.ChildNodes['SCANSTATUS'].Text = '1' then begin
            Item1.ItemData.Bitmap := Main_Form.Orange.Bitmap;
            Item1.Tag             := 1;
          end;
          if XMLNode.ChildNodes['SCANSTATUS'].Text = '2' then begin
            Item1.ItemData.Bitmap := Main_Form.Green.Bitmap;
            Item1.Tag             := 2;
          end;

          Customer := TText.Create(nil);
            Customer.Parent         := Item1;
            Customer.Position.X     := 95;
            Customer.Position.Y     := 8;
            Customer.Text           := XMLNode.childNodes['CUSTOMERNAME'].text;
            Customer.Width          := Item1.Width - 105;
            Customer.WordWrap       := False;
            Customer.Color          := TAlphaColors.Blue;
            Customer.Trimming       := TTextTrimming(1);
            Customer.Height         := 20;
            Customer.Font.Size      := 18;
            Customer.HorzTextAlign  := TTextAlign(1);
            Customer.Anchors := [TanchorKind.akLeft,TanchorKind.akRight];
            Customer.WordWrap       := False;

          Product := TText.Create(nil);
            Product.Parent        := Item1;
            Product.Position.X    := 105;
            Product.Position.Y    := 30;
            Product.Text          := 'Product: ' +XMLNode.childNodes['PRODUCT'].text;
            Product.Width         := Item1.Width - 115;
            Product.Trimming      := TTextTrimming(1);
            Product.Height        := 20;
            Product.Font.Size     := 15;
            Product.HorzTextAlign := TTextAlign(1);
            Product.Anchors := [TanchorKind.akLeft,TanchorKind.akRight];
            Product.WordWrap      := False;

          QTY := TText.Create(nil);
            QTY.Parent        := Item1;
            QTY.Position.X    := 105;
            QTY.Position.Y    := 50;
            QTY.Text          := 'QTY: ('+XMLNode.childNodes['QTY'].text+')';
            QTY.Width         := Item1.Width - 115;
            QTY.Trimming      := TTextTrimming(1);
            QTY.Height        := 20;
            QTY.Font.Size     := 15;
            QTY.HorzTextAlign := TTextAlign(1);
            QTY.Anchors := [TanchorKind.akLeft,TanchorKind.akRight];
            QTY.WordWrap      := False;

          Item1.ItemData.Detail :=  ' |' + XMLNode.childNodes['SID'].Text+'|'+
                                    ' |' + XMLNode.childNodes['CUSTOMERNAME'].Text+'|'+
                                    ' |' + XMLNode.childNodes['PRODUCT'].text+'|'+
                                    ' |' + XMLNode.childNodes['QTY'].Text+'| ';


          XMLNode := XMLNode.NextSibling;
        end;
        Main_Form.LBoxEntries.EndUpdate;

没有任何帖子操作/事件与项目相关联。

2 个答案:

答案 0 :(得分:2)

我删除了我正在使用的所有TLayouts,其中列出了我的Listbox - 仍然滞后。

然后我删除了作为表单控件的父TPanel(打开侧边菜单时的滑动效果),然后滞后消失了。我将进一步测试,看看我是否可以将TPanel与TLayout交换,或者只是相应地调整我的程序和侧面菜单。

更新:TPanel是滚动时导致lagg的原因。交换TLayout的组件,它一如既往地顺利运行!

答案 1 :(得分:1)

我认为标准建议是,如果需要滚动,使用TListView,而不是TListbox。我已经在iOS和Android上使用XE5在TListView中完成了100多个项目的简单应用程序,并且滚动非常流畅。