Flex Gumbo中如何利用useVirtualLayout属性创建虚拟布局List的例子
By Minidxer | August 26, 2009
接下来的Flex Gumbo中如何通过在useVirtualLayout属性上设置layout对象,创建虚拟布局List。
下面是main.mxml:
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application name="Spark_List_layout_useVirtualLayout_test"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/halo"
- initialize="init();">
- <fx:Script>
- <![CDATA[
- private function init():void {
- var idx:uint;
- var len:uint = 2000;
- var arr:Array = [];
- for (idx=0; idx<len; idx++) {
- arr.push("Item #" + idx);
- }
- arrList = new ArrayList(arr);
- }
- ]]>
- </fx:Script>
- <fx:Declarations>
- <s:ArrayList id="arrList" />
- </fx:Declarations>
- <s:List id="list"
- dataProvider="{arrList}"
- skinClass="skins.CustomListSkin"
- horizontalCenter="0"
- verticalCenter="0" />
- </s:Application>
下面是Skin类Skins/CustomListSkin.mxml的代码:
- <?xml version="1.0" encoding="utf-8"?>
- <s:SparkSkin name="CustomListSkin"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- minWidth="112" minHeight="112"
- alpha.disabled="0.5">
- <s:states>
- <s:State name="normal" />
- <s:State name="disabled" />
- </s:states>
- <fx:Metadata>
- <![CDATA[
- [HostComponent("spark.components.List")]
- ]]>
- </fx:Metadata>
- <fx:Script>
- /* Define the skin elements that should not be colorized.
- For list, the skin itself is colorized but the individual parts are not. */
- static private const exclusions:Array = ["scroller", "background"];
- override public function get colorizeExclusions():Array {return exclusions;}
- static private const contentFill:Array = ["bgFill"];
- override public function get contentItems():Array {return contentFill};
- </fx:Script>
- <!-- border -->
- <s:Rect left="0" right="0" top="0" bottom="0">
- <s:stroke>
- <s:SolidColorStroke color="0x686868" weight="1"/>
- </s:stroke>
- </s:Rect>
- <!-- fill -->
- <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
- <s:fill>
- <s:SolidColor id="bgFill" color="0xFFFFFF" />
- </s:fill>
- </s:Rect>
- <s:Scroller id="scroller"
- focusEnabled="false"
- horizontalScrollPolicy="off"
- left="1" top="1" right="1" bottom="1">
- <s:DataGroup id="dataGroup"
- itemRenderer="spark.skins.default.DefaultItemRenderer">
- <s:layout>
- <s:VerticalLayout gap="0"
- horizontalAlign="contentJustify"
- useVirtualLayout="true"
- requestedRowCount="6" />
- </s:layout>
- </s:DataGroup>
- </s:Scroller>
- </s:SparkSkin>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Gumbo, List |
No Comments » |
Tags: Gumbo, requestedRowCount, useVirtualLayout