Delphi - 带有ListView和TabControl的fmx中的错误

问题描述 投票:0回答:1

我有一个带有两个TabItem的TabControl。每个tabItem都有一个ListView。第一个TabItem上的listView的OnItemClick事件执行'Ne​​xtTabAction'。

问题是如果我在第二个TabItem上的listView中选择一个项目,它的TextColor是白色而不是黑色。该错误似乎是如果ListView在TabItem上而不是应用程序启动时可见的TabItem,则其selectedItem的TextColor将为White。

重现起来非常简单。我正在使用Delphi Tokyo 10.2

如果页面在启动时可见,那么它看起来就像TextColor Black

如果页面在启动时不可见,那么它看起来是另一种方式enter image description here

有办法解决这个问题吗?

listview delphi firemonkey tabcontrol
1个回答
1
投票

即使在Delphi 10.2 update 3中,这也是ListView的普通行为。只有在使用制表符转换时才会发生这种情况。

我用以下代码解决了这个问题:

procedure TForm1.ListView1UpdateObjects(const Sender: TObject; const AItem:  TListViewItem);
var
  Text: TListItemText;
begin
  Text := TListItemText(AItem.View.FindDrawable('T'));
  if Text <> nil then
    Text.SelectedTextColor := TAlphaColors.Black;
end;

当然你需要改变符合你需求的Drawable名字......

© www.soinside.com 2019 - 2024. All rights reserved.