Firemonkey Listview Dynamic Appearance Image LoadFromFile

  

I am having problem with using the FMX TListView with Dynamic appearance. Basically, in a custom appearance, I can allocate any images from file and it works fine. But when I use Dynamic appearance, the following give me run-time exception:

dynamic_cast<TListItemImage*>(item->Objects->FindDrawable(“Image2”))->Bitmap->LoadFromFile(StrFileName);

Please see my code below:

TListViewItem* item;

while(!myQuery->Eof )
{
item = ListView1->Items->Add();

TListItemText * Text1 = reinterpret_cast<TListItemText*>((const_cast<TListViewItem*>(item))->Objects->FindObject(“Text1”));

if (LCaption != NULL)
{
Text1->Text = myQuery->FieldByName(“Description1″)->AsString;
}

UnicodeString StrFileName = L”/mnt/sdcard/test.jpg”;

dynamic_cast<TListItemImage*>(item->Objects->FindDrawable(“Image2”))->Bitmap->LoadFromFile(StrFileName);

myQuery->Next();
}

Comments are closed.