와 -Multilined의 itemRenderer - 테스트 케이스 아래의 간단한 플렉스 4 웹 응용 프로그램에서 스크린 샷
은, 사용자 정의 항목 렌더러 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 : 2
<?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>
UPDATE :
내가 Creating multi-line list rows with variable row heights 블로그와 동일해야합니다 -하지만 대한 spark.components.List wh ich는 더 이상 wordWrap
속성을 가지고 있지 않습니다.
UPDATE 3 : RIAStar 내 질문 (! 덕분에) 대답 사실 후
, 내 문제는 단지 시작했다 - 나는 지금 myList.ensureIndexIsVisible(MONTHS.length - 1);
를 호출 할 때 정말 아래로 스크롤하지 않습니다. List with multilined (word wrapping) item renderer - how to scroll to the bottom? With test case and screenshots
음, 아무 것도 변경되지 않습니다. 'layout'이'MyRenderer'에 대해 설정되어야합니까? –
@AlexanderFarber 당신의 레이블이 원하는만큼 멀리 뻗을 수 있기 때문에 나는 생각합니다. 너비를 100 %로 설정해보십시오. – RIAstar
그건 이상 해요. 왜냐하면 이미 이걸 성공적으로 해 놨기 때문이죠. 나는 너에게 일하는 모범을 보이려고 노력할 것이다. – RIAstar