文件系统树项目呈现器

k2fxgqgv  于 2022-09-21  发布在  Apache
关注(0)|答案(1)|浏览(125)

我试着做了几件事,但我做不到。

1.我一直在尝试给一个mx:FileSystemTree剥皮,横向显示de data,我觉得这几乎是不可能的,有人知道怎么做吗?
1.我正在尝试的第二件事是向FileSystemTree添加一个itemRender,希望添加一对按钮(Add和Delete,我已经在使用它们了)。到目前为止,我尝试的所有操作都给出了相同的错误:TypeError: Error #1034: Type Coercion failed: cannot convert SKins::FileSystemItemRenderer@971c479 to mx.controls.listClasses.IListItemRenderer.

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                           xmlns:s="library://ns.adobe.com/flex/spark" 
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           width="750" height="500">

        <s:layout>
            <s:VerticalLayout/>
        </s:layout>
        <s:VGroup width="607" height="134">
            <s:HGroup width="607" height="68">
                <s:Button label="Button"/>
                <s:Button label="Button"/>
            </s:HGroup>
            <s:TextInput width="600"/>
        </s:VGroup>
        <mx:HDividedBox> 
            <mx:FileSystemTree id="tree" width="615" height="480" allowMultipleSelection="true"
                               borderVisible="false" defaultLeafIcon="@Embed('../assets/folder.png')"
                               directory="{new File(raiz)}" dragEnabled="true" dropEnabled="true"
                               folderClosedIcon="@Embed('../assets/folder.png')"
                               folderOpenIcon="@Embed('../assets/openFolder.png')" fontSize="45"
                               fontStyle="normal" fontWeight="normal" iconFunction="selectIcon"
                               itemRenderer="SKins.FileSystemItemRenderer" showIcons="true"
                               textAlign="left" textDecoration="none" verticalAlign="middle"/>    

        </mx:HDividedBox> 

    </s:WindowedApplication>

这是将显示树的代码。

<?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" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                autoDrawBackground="true">

    <s:Label text="{data}"/>

</s:ItemRenderer>

我已经尝试了一个简单的渲染器,收到错误#1034。

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/04/08/creating-an-alternating-item-renderer-in-a-spark-list-control-in-flex-4/ -->

<s:MXTreeItemRenderer name="IListItemRenderer"
                xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx">

    <s:HGroup id="hGr" left="4" right="4" top="4" bottom="4">
        <s:RichText id="lbl" text="({itemIndex}) {data.label}" width="100%" />
        <mx:Image id="img" source="{data.img}" toolTip="{data.img}" width="100" height="67" />
    </s:HGroup>

</s:MXTreeItemRenderer>

我也尝试了另一个渲染器,但效果相同。

j91ykkif

j91ykkif1#

我不确定是否要水平显示数据,但你关于项目呈现器的第二点对我来说很好。以下是工作代码

<?xml version="1.0" encoding="utf-8"?>
<s:MXTreeItemRenderer
                  xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark"
                  xmlns:mx="library://ns.adobe.com/flex/mx">

<s:HGroup id="hGr" left="4" right="4" top="4" bottom="4">
    <s:Rect id="indentationSpacer"
            width="{treeListData.indent}" height="22"
            alpha="0">
        <s:fill>
            <s:SolidColor color="0xFFFFFF" />
        </s:fill>
    </s:Rect>
    <s:Group id="disclosureGroup">
        <s:BitmapImage source="{treeListData.disclosureIcon}"
                       width="16" height="16"
                       visible="{treeListData.hasChildren}" />
    </s:Group>
    <s:BitmapImage source="{treeListData.icon}"
                   width="16" height="16"/>
    <s:RichText id="lbl" text="{data.nativePath}" toolTip="{data.nativePath}" width="100%" maxDisplayedLines="1"  />

    <s:Button label="Button"/>
    <s:Button label="Button"/>
</s:HGroup>

相关问题