Hello,
I'm using Delphi 10.1 Berlin to develop an Android app.
As of recommendation from here (to solve performance issues) I use a TListView.
I can add items by code and I managed to set the background color by:
1. adding a TStyleBook on the form, loading one of the supplied styles into it
2. double clicking on that one to open the style editor
3. unfolding listviewstyle and changing the Color of the background item
This works.
Now I tried to do the same in code, but it failed.
I created an OnApplyStyleLookup event for the ListView:
procedure TForm1.ListView1ApplyStyleLookup(Sender: TObject);
var
Obj: TFMXObject;
begin
if (Sender is TListView) then
begin
Obj := TListView(Sender).FindStyleResource('itembackground');
if assigned(Obj) then
if Obj is TColorObject then
TColorObject(Obj).Color := claSlategray;
end;
end;
1. It never got called (says the debugger)
2. I added a ListView1.NeedStyleLookup; call to the OnStartShowing event
of the TMultiview the ListView is on. Then it got called and I can step through it and verify,
that the line assigning the color is actually being called.
But: at runtime the listview still has a white background!
StyleLookup of that Listview is the default one 'listviewstyle'.
So why is the OnStyleLookup never called without my manual triggering?
And why doesn't it change the backgroudn color when I manually trigger it?
Greetings
Markus
Connect with Us