Flex中如何通过给alternatingItemColors样式设置一个颜色数组使树Tree节点颜色交替的例子

By Minidxer | December 23, 2008

接下来的例子演示了Flex中如何通过给alternatingItemColors样式,设置一个颜色数组使树Tree节点颜色交替。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white">
  6.  
  7.     <mx:XMLListCollection id="xmlListColl">
  8.         <mx:source>
  9.             <mx:XMLList>
  10.                 <node label="One">
  11.                     <node label="One.1" />
  12.                     <node label="One.2" />
  13.                     <node label="One.3" />
  14.                 </node>
  15.                 <node label="Two">
  16.                     <node label="Two.1" />
  17.                     <node label="Two.2" />
  18.                     <node label="Two.3" />
  19.                 </node>
  20.             </mx:XMLList>
  21.         </mx:source>
  22.     </mx:XMLListCollection>
  23.  
  24.     <mx:Tree id="tree"
  25.             dataProvider="{xmlListColl}"
  26.             labelField="@label"
  27.             alternatingItemColors="[#DFDFDF,#EEEEEE]"
  28.             rowCount="4"
  29.             width="300" />
  30.  
  31. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Tree | No Comments » | Tags: ,

Search Posts