如何在 Spark List 控件中的项目之间添加分隔符
我有 as:List ,我在其中定义了自己的 itemRenderer,并且想要插入分隔项目的水平线,类似于 mx:LinkBar 的工作方式。我不想在列表的顶部或底部有一行,所以我不能只在 itemRenderer 中包含上边框或下边框。我希望 itemRenderer 能够知道它在列表中的索引,但我不知道如何做到。有办法做到这一点吗?
I have a s:List where I've defined my own itemRenderer, and would like to insert a horizontal line separating items, similar to the way the mx:LinkBar works. I don't want to have a line at the top or bottom of the list, so I can't just include an upper or lower border in the itemRenderer. I was hoping the itemRenderer could be made aware of its index in the list, but I don't see how. Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“我希望 itemRenderer 能够知道其在列表中的索引,但我不知道如何实现。有办法做到这一点吗?”
如果您的 itemRenderer 实现了 IDropInListItemRenderer 接口,那么您只能访问 listData 对象的 rowIndex 属性。
" I was hoping the itemRenderer could be made aware of its index in the list, but I don't see how. Is there a way to do this?"
If your itemRenderer implements the IDropInListItemRenderer interface, you can just access the rowIndex property of the listData object.
我发现的最干净的解决方案是在项目之间放置一个间隙,并让背景矩形(或其他东西)在项目之间显示。要在 List 上执行此操作,您只需重新设计它并自定义 VerticalLayout 以具有间隙。
The cleanest solution I've found to this is to put a gap between the items and let a background Rect (or something) show through between the items. To do this on List you can just reskin it and customize the VerticalLayout to have a gap.