星火列表按钮星火、按钮、列表

由网友(成王败寇是规则。)分享简介:我有一个Spark列表包括填写表单应用程序列表的数据提供者。什么是添加一个按钮,每个列表项(窗体应用程序)的最佳方法是什么?此按钮将被命名为开放式,并定位到指定的表单应用程序。I have a Spark List with a data provider consisting of a list of filled...

我有一个Spark列表包括填写表单应用程序列表的数据提供者。什么是添加一个按钮,每个列表项(窗体应用程序)的最佳方法是什么?此按钮将被命名为开放式,并定位到指定的表单应用程序。

I have a Spark List with a data provider consisting of a list of filled out form applications. What is the best way to add a button to each List Item (form application)? This button will be named Open and will navigate to the specified form application.

在此先感谢您的任何建议!

Thanks in advance for any advice!

推荐答案

这是类似于@ www.Flextras.com说,所以我不打算重复。不过,我将添加一个例子,一两件事情。

This is similar to what @www.Flextras.com said, so I'm not going to repeat that. However, I'll add an example and one or two things.

您定义ItemRenderer可能是这样的:

Your custom ItemRenderer might look like this:

<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark">

    <fx:Script>
        <![CDATA[
            import mx.events.ItemClickEvent;

            private function requestForm():void {
                var event:ItemClickEvent = new ItemClickEvent(ItemClickEvent.ITEM_CLICK);
                event.index = itemIndex;
                event.item = data;
                owner.dispatchEvent(event);
            }
        ]]>
    </fx:Script>

    <s:Label id="labelDisplay" verticalCenter="0" />
    <s:Button right="0" label="open" verticalCenter="0" click="requestForm()" />

</s:ItemRenderer>

两件事情,从Flextras的回答有所不同:

Two things that differ from Flextras' answer:

我用的是内置的,而不是一个自定义事件ItemClickEvent>少 编码 在我派遣的所有者事件的itemRenderer,哪个 实际上包含此的ItemRenderer列表。因为这个, 你不需要泡沫事件。 I use the built-in ItemClickEvent instead of a custom event > less coding I dispatch the event on the owner of the ItemRenderer, which is in fact the List that contains this ItemRenderer. Because of this, you don't need to bubble the Event.

现在,打开按钮被点击时的形式,做这样的事情:

Now to open the form when the Button is clicked, do something like this:

myList.addEventListener(ItemClickEvent.ITEM_CLICK, openForm);

private function openForm(event:ItemClickEvent):void {
    trace("open " + event.item.toString());
}
阅读全文

相关推荐

最新文章