如何在Flex 4.6移动项目中制作动态列表组件?

时间:2012-01-04 18:41:23

标签: android flex mobile

如何在Flex 4.6移动项目中更改我的列表组件,当按下某个项目时,它会动态调整大小并显示文章描述和按钮

这里是预览: https://lh4.ggpht.com/GObdGVeDrLW_A-4_ZwuXzh21UY_JyT1P4RdpY6KYYMkW2L8rA08apQllt8cDpcM14w

谢谢

1 个答案:

答案 0 :(得分:1)

在列表中使用ItemRenderer。在该项呈示器中,您可以使用标签,组,列表按钮以及您想要的任何内容

E.g。这是主要清单

<s:List id="t_list"  width="100%" height="100%" itemRenderer="itemrenderer.ticketItemRenderer_One" contentBackgroundAlpha="0" left="5" right="5">
    <s:layout>
        <s:VerticalLayout gap="4" horizontalAlign="right" />
    </s:layout>
</s:List>

这是您可以用户的项目渲染器代码

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                    xmlns:s="library://ns.adobe.com/flex/spark"  height="65" autoDrawBackground="false" click="itemrenderer1_clickHandler(event)"  >

    <fx:Style source="creobill.css" />

    <fx:Script>
        <![CDATA[

            import assets.triangle_white;

            import views.utilities;
        /*  open
            awaiting
            closed
            in progress */


            protected function itemrenderer1_clickHandler(event:MouseEvent):void
            {
            //  this.parentApplication.accountVN.pushView(utilities);
            }

        ]]>
    </fx:Script>


    <s:BitmapImage source="{triangle_white}" height="10" x="10" y="20" width="10" alpha="1" rotation="90" smooth="true" smoothingQuality="high"/>
    <s:Rect top="0" bottom="0" right="0" left="10" x="10" radiusY="4" radiusX="4" alpha="1" >
        <s:fill>
            <s:LinearGradient >
                <s:GradientEntry color="#ffffff" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>    
    <s:VGroup left="13" right="6" top="3" bottom="3" x="5" gap="2" horizontalAlign="center"  verticalAlign="middle">

    <s:HGroup  width="100%" height="50%" horizontalAlign="left" verticalAlign="middle">
        <s:Label id="t_subject" width="100%" height="100%" fontWeight="bold" styleName="content"
                 text="{data.subject}" />

    </s:HGroup> 



    <s:HGroup width="100%" height="50%" horizontalAlign="left" verticalAlign="middle">
        <s:Label id="y_list_replier" width="70%" height="100%" fontStyle="italic" styleName="content"
                 text="{data.lastreplier}" verticalAlign="middle"/>
        <s:Label id="t_status" width="30%" color="#373737" fontWeight="bold" styleName="labels"
                 text=" {data.ticketstatustitle}" textAlign="right"/>
    </s:HGroup>
        <s:Label id="t_last_update" width="100%" color="#585858" fontWeight="bold" styleName="labels"
                 text="Updated: {data.lastactivity}" textAlign="right" verticalAlign="middle"/>
</s:VGroup>
</s:ItemRenderer>

通过这种方式,您可以添加按钮并设置单击方法以显示或隐藏所需的组件