如何在运行时更改android应用程序中TlistBoxItem的属性?

如何在运行时更改android应用程序中TlistBoxItem的属性?,android,delphi,listbox,delphi-xe,listboxitem,Android,Delphi,Listbox,Delphi Xe,Listboxitem,在我的程序中,我创建了一个函数,用于读取博客的xml,并将标题放在一个TListBox中。但我需要更改TListBoxItem中的一些属性,如字体、高度和颜色,但它不会更改 如何在运行时设置它 repeat Title := ANode.ChildNodes['title'].Text; Link := ANode.ChildNodes['link'].Text; Desc := ANode.ChildNodes['description'].Text; DataPub := A

在我的程序中,我创建了一个函数,用于读取博客的xml,并将标题放在一个TListBox中。但我需要更改TListBoxItem中的一些属性,如字体、高度和颜色,但它不会更改

如何在运行时设置它

repeat
  Title := ANode.ChildNodes['title'].Text;
  Link := ANode.ChildNodes['link'].Text;
  Desc := ANode.ChildNodes['description'].Text;
  DataPub := ANode.ChildNodes['pubDate'].Text;
  SetLength(Vet_News, Pos + 1);
  Vet_Nesw[Pos] := '<h2>'+Title+'</h2>'+Desc;
  Itemx := TListBoxItem.Create(self);
  Itemx.Text := Title;
  Itemx.ItemData.Detail := DataPub;
  Itemx.ItemData.accessory := TListBoxItemData.TAccessory.aMore;
  Itemx.TextSettings.WordWrap := true;
  Itemx.TextSettings.FontColor := TAlphaColorRec.Darkorange;
  Itemx.Height := 65;
  Itemx.FontColor := TAlphaColorRec.Darkorange; // i tried two ways to change the color
  lbNews.AddObject(Itemx); // lbnews is a Tlistbox 
  Inc(Pos);
  ANode := ANode.NextSibling;
until ANode = nil;
[使用Delphi-XE7进行测试] 在运行时,Listboxitems已具有存储在中的计算样式:aListboxItem.StyledSettings。 要在运行时更改设置,首先必须将其从样式设置列表中删除

例如,如果要更改FontColor,请首先删除已设置样式的FontColor:

aListboxItem.StyledSettings := aListboxItem.StyledSettings - [TStyledSetting.FontColor];
然后应用另一个,比如绿色:

aListboxItem.FontColor := TAlphaColors.Green;
将列出TStyledSetting常量和相应的TTextSettings属性

在运行时更改样式的示例可以找到和

Nota Bene:theListBox.Items[i]允许访问项目内容,而不是项目本身。 要获取ListboxItem作为控件,然后对其属性进行操作,可以使用:

aListboxItem := theListBox.ListItems[i];


两者给出的结果完全相同,我不能说哪一个更好。

您可能需要更改TListBox或列表框项目的样式。另一个主意?只有在运行时我才能更改设置。是否通过项目的样式查找?更改项目正在使用的样式,或更改查找以引用新样式。否则,请你扩大你的问题,好吗?
aListboxItem := theListBox.ItemByIndex(i);