Как изменить стиль Adobe Flex Accordion, чтобы включить кнопку в каждый заголовок холста?

StackOverflow https://stackoverflow.com/questions/11665

  •  08-06-2019
  •  | 
  •  

Вопрос

Вот пример кода моего аккордеона:

<mx:Accordion x="15" y="15" width="230" height="599" styleName="myAccordion">
    <mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off">
        <mx:VBox width="100%" height="80%" paddingTop="2" paddingBottom="1"  verticalGap="1">
            <mx:Repeater id="rptrSpotlight" dataProvider="{aSpotlight}">            
                <sm:SmallCourseListItem 
                    viewClick="PlayFile(event.currentTarget.getRepeaterItem().fileID);"
                    Description="{rptrSpotlight.currentItem.fileDescription}"
                    FileID = "{rptrSpotlight.currentItem.fileID}"   
                    detailsClick="{detailsView.SetFile(event.currentTarget.getRepeaterItem().fileID,this)}" 
                    Title="{rptrSpotlight.currentItem.fileTitle}"
                    FileIcon="{iconLibrary.getIcon(rptrSpotlight.currentItem.fileExtension)}" />
            </mx:Repeater>
        </mx:VBox>
    </mx:Canvas>
</mx:Accordion>

Я хотел бы включить кнопку в каждый заголовок следующим образом:

wishful

Это было полезно?

Решение

Спасибо, я заработал, используя FlexLibCanvasButtonAccordionHeader.

Другие советы

Вам придется создать собственный визуализатор заголовка, добавить к нему кнопку и расположить ее вручную.Попробуйте что-то вроде этого:

<mx:Accordion>
    <mx:headerRenderer>
        <mx:Component>
            <AccordionHeader xmlns="mx.containers.accordionClasses.*">
                <mx:Script>
                <![CDATA[

                import mx.controls.Button;


                private var extraButton : Button;


                override protected function createChildren( ) : void {
                    super.createChildren();

                    if ( extraButton == null ) {
                        extraButton = new Button();

                        addChild(extraButton);
                    }
                }

                override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number ) : void {
                    super.updateDisplayList(unscaledWidth, unscaledHeight);

                    extraButton.setActualSize(unscaledHeight - 6, unscaledHeight - 6);
                    extraButton.move(unscaledWidth - extraButton.width - 3, (unscaledHeight - extraButton.height)/2);
                }

                ]]>
                </mx:Script>
            </AccordionHeader>
        </mx:Component>
    </mx:headerRenderer>

    <mx:HBox label="1"><Label text="Text 1"/></HBox>
    <mx:HBox label="1"><Label text="Text 2"/></HBox>
    <mx:HBox label="1"><Label text="Text 3"/></HBox>
</mx:Accordion>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top