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

  

I’ve created an app in Delphi 10.1 Berlin using Windows as the Master View. I dropped a TListView on the form and customized it using the new Toggle Design Mode. I added a TImageObjectAppearance and several TTextObjectAppearance items. I added code to set the image for the TImageObjectAppearance and the text items have various font sizes and style. I also have 3 TImage components on the form that I use to assign to the TImageObjectAppearance.Bitmap based on a value.

When I compile it for Win32 and run it eveything looks great. The bitmap images display based on the value on each row of the TListView. When I switch the Style to Android and the View to Android 10″ Tablet the IDE throws this error:

“Cannot assign a TAppearanceObjectItem to a 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…

So I switched back to Style: Windows and View: Master. I clicked on the TImageObjectAppearance item on the form and pressed the Delete key and I got this error:

“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. 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. 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.

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?

Thanks
-Barry

Comments are closed.