<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var myDataProvider:ArrayCollection = new ArrayCollection([
{data:1, label:"One", desc:"Here is a toolTip description of the item One"},
{data:2, label:"Two", desc:"Here is a toolTip description of the item Two"},
{data:3, label:"Three", desc:"Here is a toolTip description of the item Three"},
{data:4, label:"Four", desc:"Here is a toolTip description of the item Four"},
{data:5, label:"Five", desc:"Here is a toolTip description of the item Five"}
]);
]]></fx:Script>
<s:List dataProvider="{myDataProvider}">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<fx:Script><![CDATA[
override public function set data(value:Object):void
{
super.data = value;
}
[Bindable]
private function getToolTip():String
{
return data.desc;
}
]]></fx:Script>
<s:Label text="{data.label}" toolTip="{getToolTip()}" width="100%"/>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
</s:Application>
2条答案
按热度按时间new9mtju1#
如果
list
中显示的label
与您要显示的toolTip
不同,则可以使用Sumit的答案中Label
的toolTip
属性,如下所示:aor9mmx12#
如果您希望在数据宽度大于List宽度时显示工具提示,则可以使用内联itemrenderer。