简体   繁体   English

柏林德尔福:FMX-TListView,可在Windows和Android之间切换

[英]Delphi Berlin: FMX-TListView, switching between Windows & Android

I've created an app in Delphi 10.1 Berlin using Windows as the Master View. 我已经使用Windows作为主视图在Delphi 10.1 Berlin中创建了一个应用程序。 I dropped a TListView on the form and customized it using the new Toggle Design Mode. 我在窗体上放置了一个TListView,并使用新的Toggle设计模式对其进行了自定义。 I added a TImageObjectAppearance and several TTextObjectAppearance items. 我添加了一个TImageObjectAppearance和几个TTextObjectAppearance项目。 I added code to set the image for the TImageObjectAppearance and the text items have various font sizes and style. 我添加了代码来设置TImageObjectAppearance的图像,并且文本项具有各种字体大小和样式。 I also have 3 TImage components on the form that I use to assign to the TImageObjectAppearance.Bitmap based on a value. 我在窗体上还具有3个TImage组件,这些组件用于根据值分配给TImageObjectAppearance.Bitmap。

When I compile it for Win32 and run it eveything looks great. 当我为Win32编译并运行它时,显示效果很棒。 The bitmap images display based on the value on each row of the TListView. 位图图像基于TListView每行上的值显示。 When I switch the Style to Android and the View to Android 10" Tablet the IDE throws this error: 当我将样式切换为Android,将视图切换为Android 10“平板电脑时,IDE会引发以下错误:

"Cannot assign a TAppearanceObjectItem to a TAppearanceObjectItem." “无法将TAppearanceObjectItem分配给TAppearanceObjectItem。”

The View still says Android 10" Tablet but the actual view on the form is still a Windows form. So my first question is what the heck is that error all about? I thought Delphi was supposed to be able to compile to all these different targets/devices using the same code. That's certainly not happening. But wait, there's more... 视图仍然显示为Android 10“ Tablet,但表单上的实际视图仍然是Windows表单。所以我的第一个问题是错误到底是什么呢?我认为Delphi应该能够编译为所有这些不同的目标/ devices使用相同的代码。这肯定不会发生。但是,等等,还有更多...

So I switched back to Style: Windows and View: Master. 所以我切换回样式:Windows和视图:主。 I clicked on the TImageObjectAppearance item on the form and pressed the Delete key and I got this error: 我单击窗体上的TImageObjectAppearance项目,然后按Delete键,出现此错误:

"Cannot delete a persistent reference from the designer." “无法从设计器中删除永久性引用。”

But if you click on the item in the Structure window and press Delete it deletes just fine. 但是,如果您在“结构”窗口中单击该项目,然后按Delete,则可以删除。 Bug? 错误? I would say so. 我会这样说。 Anyway, there's more.I deleted the TImageObjectAppearance item from the Structure window and then switched back to Style: Android and View: Android 10" Tablet and guess what...I get the same error. But there is not TImageObjectAppearance on the form! So I completely delete the TListView custom items in Windows | Master view and start fresh using Android 10" Tablet view. 无论如何,还有更多的东西。我从“结构”窗口中删除了TImageObjectAppearance项,然后切换回“样式:Android和视图:Android 10”平板电脑,然后猜测是什么...我遇到相同的错误。但是窗体上没有TImageObjectAppearance!因此,我完全删除了Windows | Master视图中的TListView自定义项,并使用Android 10“ Tablet视图重新开始。 I add all the custom appearance objects, including the TImageObjectAppearnce.But when I compile it for a 10" Android tablet and run it on my Galaxy Tab S2, 1) No images appear.Here's the code I wrote to set the images. (There are 3 TImage components on the form that I use for the TImageObjectAppearance items.) This code works just fine when compiling for Win32. 我添加了所有自定义外观对象,包括TImageObjectAppearnce。但是,当我将其编译为10英寸Android平板电脑并在Galaxy Tab S2上运行时,1)没有图像出现。这是我编写的用于设置图像的代码。是用于TImageObjectAppearance项的窗体上的3个TImage组件。)在为Win32编译时,此代码工作得很好。

function TdmVisual.AddOrUpdateItem(AItem: TListViewItem; AMGDL: Integer): TListViewItem;
var
  LObject: TListItemImage;

begin
  Result         := AItem;
  LObject        := Result.Objects.FindObjectT<TListItemImage>('imgRating');
  LObject.Bitmap := TBitmap.Create;

  if AMGDL < 70 then
    LObject.Bitmap.Assign(fmMain.iLow.Bitmap)
  else if (AMGDL >= 70) and (AMGDL <= 130) then
    LObject.Bitmap.Assign(fmMain.iGreen.Bitmap)
  else if (AMGDL > 130) and (AMGDL <= 180) then
    LObject.Bitmap.Assign(fmMain.iYellow.Bitmap)
  else
    LObject.Bitmap.Assign(fmMain.iRed.Bitmap);
end;

My second (3rd or 4th) question is why does the above code not work when compiling for Android and what's the proper way to assign images to a TImageObjectAppearance in code? 我的第二个(第3个或第4个)问题是,为什么在为Android编译时上述代码为何不起作用,以及在代码中将图像分配给TImageObjectAppearance的正确方法是什么?

Thanks -Barry 谢谢-巴里

this is a bug 这是一个错误

""Cannot assign a TAppearanceObjectItem to a TAppearanceObjectItem" has been logged as a bug in our quality portal:" “”无法将TAppearanceObjectItem分配给TAppearanceObjectItem“已在我们的质量门户网站中记录为错误:”

https://community.embarcadero.com/forum/ui/1953-fmx-tlistview-switching-between-windows-android https://community.embarcadero.com/forum/ui/1953-fmx-tlistview-switching-between-windows-android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM