I am using Delphi XE5 Professional to develop Android App. App is running on my Galaxy S3 phone with Android 4.1.2. I probabbly don't understand, how does TStringList works. Here is what I am trying
In my FireMonkey Mobile Form I have 4 TEdits named: edt1, edt2, edt3, edt4
First I create List: TStringList
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
List := TStringList.Create;
for i := 1 to 4 do List.Add(IntToStr(i));
end;
with an obvious structure [1 2 3 4]. Then I delete 2nd Item:
procedure TForm1.btnDeleteItem;
begin
List.BeginUpdate;
List.Delete(1);
List.EndUpdate;
end;
After this procedure List has structure [1 3 4]. Problems come with the next procedure - here I try to copy data from List to my edits, so edt1 contains List[0], edt2 contains List[1],... Here is code for doing so:
procedure TForm1.HandleEditButtons(Sender: TObject);
var i: Integer;
aEdt: TEdit;
begin
for i := 1 to 4 do
begin
aEdt := FindComponent('edt'+IntToStr(i)) as TEdit;
if (aEdt <> nil) then
if (i <= List.Count) then aEdt.Text := List[i-1]
else aEdt.Text := '';
end;
end;
After this procedure, List has structure [1 2 3] so it seems to me, when with procedure btnDeleteItem the last item was from List Deleted. Structures of List, which I present here, was got by using Memo1.Lines.Add(List.Text) between procedures.
Does anyone has any idea, what is happening here?