[英]How to show a tooltip on a Spark List
I have a Spark List and I want to show a tool tip when over a row. 我有一个“火花列表”,并且想在连续显示一个工具提示。 In the previous List I think there was a dataTipField property but I don't see that on the Spark List.
在上一个List中,我认为有一个dataTipField属性,但在Spark List上没有看到它。
If the label
displayed in the list
is different than the toolTip
you want to show then you can use toolTip
property of the Label
in Sumit's answer as below: 如果
list
显示的label
与您要显示的toolTip
不同,则可以在Sumit的答案中使用Label
toolTip
属性,如下所示:
<?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>
If you want to show the tooltip when the data width is more than the List width then you can use inline itemrenderer for it. 如果要在数据宽度大于列表宽度时显示工具提示,则可以使用内联itemrenderer。
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Label text="{data.Expense}"
width="100"
maxDisplayedLines="1"
showTruncationTip="true" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.