How to execute an ActionList item from a TListViewItem

  

I’m trying to execute an action (TakePhotoFromCameraAction) in a TActionList, when a TListViewItem is selected.

Neither TlistView nor TListViewItem have an Action property, so I’ve tried calling ActionList[0].Execute in the event, but nothing happens.

Any ideas?

Further:
The code is very simple, as it was just a test for this problem. I was focussing on the ActionList as that was what I will use (when I sort it out).
Button1 doesn’t work (it always fails, even when button 2 doesn’t), whereas the (new) Button2 does work OK.

type
TForm1 = class(TForm)
ActionList1: TActionList;
Memo1: TMemo;
TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
begin
ActionList1[0].Execute;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if TakePhotoFromCameraAction1.Execute
then
Memo1.Lines.add(‘Photo OK’)
else
Memo1.Lines.add(‘Photo Fail’);
end;

Comments are closed.