Lista com renderizador de itens com múltiplas linhas (quebra de linha) - como rolar para baixo? Com caso de teste e screenshots
Em um aplicativo da Web do Flex 4, estou tentando usarspark.components.List para um bate-papo (por várias razões - funciona bem para mim em um aplicativo móvel Flex já), mas porque eu uso um representante de item que pode ser multilinha (ou seja, envolve linhas muito longas) eu tenho o problema, que eu não posso rolar o listar a sua parte inferior chamando seuensureIndexIsVisible
método:
Eu preparei um teste muito simples. Estes são apenas 2 arquivos, que funcionarão instantaneamente, quando você os colocar em um novo projeto Flex no Flash Builder -
MyApp.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"
applicationComplete="init()">
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
private static const MONTHS:ArrayList = new ArrayList([
"1 January is a beautyful month",
"2 February is a very very very very very very very very very very very very very very very 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"
]);
private function init():void {
myList.ensureIndexIsVisible(MONTHS.length - 1);
}
]]>
</fx:Script>
<s:List id="myList"
horizontalCenter="0"
verticalCenter="0"
width="100"
height="300"
dataProvider="{MONTHS}"
itemRenderer="MyRenderer"
horizontalScrollPolicy="off">
<s:layout>
<s:VerticalLayout variableRowHeight="true"
horizontalAlign="justify"/>
</s:layout>
</s:List>
</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 data(value:Object):void {
var label:String = value as String;
labelDisplay.text = label;
if (label.indexOf("June") >= 0)
myColor = 0xFFEEEE;
else if (label.indexOf("July") >= 0)
myColor = 0xEEFFEE;
else if (label.indexOf("August") >= 0)
myColor = 0xEEEEFF;
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"
width="100%"
left="4"
top="4" />
</s:ItemRenderer>
Por favor, dê uma olhada e me avise, como rolar a lista para a sua parte inferior.
Eu deveria de alguma forma usarmyList.dataGroup
por isso? Ou talvez olayout.verticalScrollPosition
?
Eu também tenteicallLater(myList.ensureIndexIsVisible, [MONTHS.length - 1])
mas isso não ajudou.