在简单的Flex 4的Web应用程序如下 -
是有可能改变的自定义项呈示MyRenderer
,所以它包裹得排长队?
TestApp.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
private static const MONTHS:ArrayList = new ArrayList([
"1 January is a beautyful month",
"2 February is a beautyful month",
"3 March is a beautyful month",
"4 April is a beautyful month",
"5 May is a beautyful month",
"6 June is a beautyful month",
"7 July is a beautyful month",
"8 August is a beautyful month",
"9 September is a beautyful month",
"10 October is a beautyful month",
"11 November is a beautyful month",
"12 December is a beautyful month"
]);
]]>
</fx:Script>
<s:List id="myList"
width="60"
dataProvider="{MONTHS}"
itemRenderer="MyRenderer" />
</s:Application>
MyRenderer.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
autoDrawBackground="false">
<fx:Script>
<![CDATA[
[Bindable]
public var myColor:uint = 0xFFFFFF;
override public function set label(value:String):void
{
super.label = value;
labelDisplay.text = label;
// var list:List = owner as List;
// if (list)
// labelDisplay.width = list.width;
if (label.indexOf("June") >= 0)
myColor = 0xFF0000;
else if (label.indexOf("July") >= 0)
myColor = 0x00FF00;
else if (label.indexOf("August") >= 0)
myColor = 0x0000FF;
else
myColor = 0xFFFFFF;
}
]]>
</fx:Script>
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="{myColor}" />
</s:fill>
</s:Rect>
<s:Label id="labelDisplay" />
</s:ItemRenderer>
更新2:
我需要一样,在可变行高度创建多行表行博客-但对于spark.components.List不具备wordWrap
属性了。
更新3:
(!感谢)RIAStar回答我的问题其实后,我的问题才刚刚开始-当我现在请myList.ensureIndexIsVisible(MONTHS.length - 1);
它并没有真正滚动至底部。
我已经准备了一个新的问题: 列出与multilined(自动换行)项目渲染-如何滚动到底部? 随着测试案例和屏幕截图