TableView GetItem and Android

Subject : TableView GetItem and Android

I have a TMSFMXTableView on the form. My code has worked successfully under Windows.

The first time it ran under Android it crashed in GetItem in Unit FMX.TMSTableView.

function TTMSFMXTableViewItems.GetItem(
  Index: Integer): TTMSFMXTableViewItem;
begin
  Result := TTMSFMXTableViewItem(inherited Items[Index]);
end;

The calling unit is attempting to remove all the design time rows:

  {Remove any design time rows}
  for iIterate := tviewBillingPeriod.Items.Count - 1 downto 0 do
    tviewBillingPeriod.Items[iIterate].Destroy;

This does work under Windows.

Would you know what changes do I need to make for it to work under Android?

Regards,
  Peter Evans

I have now tried:-

var
  TableViewItem       :  TTMSFMXTableViewItem;

begin
for iIterate := tviewBillingPeriod.Items.Count - 1 downto 0 do begin
    TableViewItem := tviewBillingPeriod.Items[iIterate];
    TableViewItem.Destroy;
  end;

Got same problem.
There is one event on the TableView.
So I also coded :-

tviewBillingPeriod.OnItemSelected := Nil;
...
tviewBillingPeriod.OnItemSelected := tviewBillingPeriodItemSelected;

Unfortunately I got same problem.

I have had to delete all the Design Time rows. This solution works.

However I do not like this approach. It still want to delete the Design Time rows programmatically.

Hi, 


Can you Try to use a DisposeOf instead of a Destroy?

Thank you.
Using DisposeOf worked under Android.