Flex List行背景色
来源:互联网 发布:易企秀源码怎么泄露了 编辑:程序博客网 时间:2024/05/24 01:40
过去在对DataGrid设置行背景色时,感觉还是挺方便的,只要重写DataGrid的,如下
如果你还是不是很明白可以参考我以前的博客http://blog.csdn.net/terryzero/archive/2009/10/12/4657277.aspx
今天我碰到个需求是要对List行变色,由于我想DataGrid和List都是继承与ListBase,都有 override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
这个方法,所以我就想当然,照葫芦画瓢,也重写了这个方法,但经过调试怎么也调用不到这个方法。搞的我非常费解,难道这个方法没用的啊?网上查了好久,国内没啥这方面的好文章,突然一篇国外的文章启发了我。如下
All the listy components in Flex (List, Datagrid, Tree, etc.) have a protected method called drawRowBackground which is in charge of drawing the background for a given row. You typically use it to color a given row based on some facet of the data the row represents (e.g. red background for rows with a negative bank balance).
With DataGrid, it's easy to use, just subclass DataGrid and override the method, parameterized so you can pass in a function to compute the color for each row based on the row index/data/original color/etc. With List (and since ComboBox uses a List, ComboBox too), it's a bit nastier.
For some reason, List will only call drawRowBackground if the 'alternatingItemColors' style is set for the List. So if you want to color your List rows, you have to supply that style, which you'll likely immediately be overriding.
原来List也有alternatingItemColors属性,设了以后问题果然解决了,如下
<wn:MOBColorList id="nodeList" width="50%" height="100%" dropEnabled="true" dataProvider="{nodes}"
dragOver="doDragOver(event)" dragEnter="doDragEnter(event)" keyDown="deleteField(event)"
alternatingItemColors="[0xEEEEEE, 0xDFDFDF]"
dragDrop="doDragDrop(event)" iconFunction="{IconUtil.setHierarchyTreeNodeIcons}"
rowColorFunction="setCustomColor"/>
其实我根本不希望行交替变色,所以就把alternatingItemColors="[0xFFFFFF, 0xFFFFFF]",哈哈搞定了,但还不是很清楚为什么一定要设。研究了下List的源码,使我茅舍顿开,如下
原来不设定alternatingItemColors根本不会调用drawRowBackgrounds方法,而DataGrid这种控件alternatingItemColors有默认值,所以一定会调用。不要把flex看的很绚丽很简单,其实还是有很多值得研究的地方,flex本身也不是很成熟,深入源码还有很多不尽人意的地方。
- Flex List行背景色
- flex datagrid 动态设置行背景色
- 改变Flex DataGrid 行的背景色
- 改变Flex DataGrid 行的背景色
- 可以动态添加行背景色的flex datagrid控件
- Flex设置LinkButton的背景色
- 设置gridview行背景色
- Jquery 行选中背景色
- List Control里插入ICO图标及行背景色交替改变
- List Control里插入ICO图标及行背景色交替改变
- 背景色
- 背景色
- flex 设置h默认背景色,颜色和帧速
- 如何改变Flex程序的默认背景色
- Flex DataGrid单元格背景色 单元格字体颜色控制
- GridView , 正常行背景色,交替行背景色,鼠标指向行背景色,鼠标点击后背景色
- css设置表格奇偶行背景色
- 设置tableview选中行的背景色
- JQuery笔记(表单验证) 三
- ubuntu下添加环境变量
- 整数三角形题目两则
- 南京特色小吃全攻略
- 完美代码-----读书笔记(1) 敏捷世界的代码质量
- Flex List行背景色
- 算法导论 ch13 红黑树
- Inno Setup添加Path变量
- 新看高质量程序设计,新见识的知识点
- 有了HTML5,Flash还能走多远?
- java反射机制
- 更改数据库SID
- 开始写博客
- 如何删除oracle实例