本文介绍了在Spark TabBar中隐藏选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个火花TabBar,我想隐藏和显示一些外部用户输入的元素(即复选框检查)

我遇到了麻烦标签的可见性。他们目前总是显示。

有没有人有任何想法?我在mx TabBar上看到了一个getTabAt,但是这个标签的外观很重要,并且要求它看起来像一个标签栏,而不是一个按钮栏。



我的代码为标签和隐藏和显示如下:

 < fx:Script> 
<![CDATA [
import mx.containers.VBox;
导入mx.controls.Label;

private function onCreationComplete():void {
var vbox1:VBox = new VBox();
vbox1.label =Tab 1;
var lbl1:Label = new Label()
lbl1.text =Panel1;
vbox1.addChild(lbl1);
dp.addChild(vbox1);

var vbox2:VBox = new VBox();
vbox2.label =Tab 2;
var lbl2:Label = new Label()
lbl2.text =Panel 2;
vbox2.addChild(lbl2);
dp.addChild(vbox2);


private function showTab(event:MouseEvent):void {
makeVisible(true);


private function hideTab(event:MouseEvent):void {
makeVisible(false);


private function makeVisible(vis:Boolean):void {
VBox(dp.getChildAt(0))。visible = vis;
VBox(dp.getChildAt(0))。enabled = vis;
VBox(dp.getChildAt(0))。includeInLayout = vis;
}
]]>
< / fx:Script>
< s:VGroup>
< mx:ViewStack width =100%height =100%id =dpborderStyle =solid/>

< / s:VGroup>

任何建议大大收到

/ p>

解决方案

这个函数会隐藏特定索引处的选项卡。如果你没有includeInLayout,那么这个选项卡就会消失,并留下一个洞。

  private function setTabEnabled(index:int,enabled: Boolean):void {
var theTab:UIComponent = tabNavigator.dataGroup.getElementAt(index)as UIComponent;
if(theTab)
theTab.visible = enabled;
theTab.includeInLayout =启用;
}
}


I have a spark TabBar and I want to hide and show some elements of it from an external user input (namely a checkbox check)

I am having trouble changing the tabs visibility. They are currently always shown.

Does anyone have any idea? I have seen a getTabAt on the mx TabBar but the look of the tab is important and the requirement is for it to look like a tab bar rather than a button bar.

My code for the tabs and for hiding and showing is below:

<fx:Script>
    <![CDATA[
    import mx.containers.VBox;
    import mx.controls.Label;

    private function onCreationComplete():void {
        var vbox1:VBox = new VBox();
        vbox1.label = "Tab 1";
        var lbl1:Label = new Label()
        lbl1.text = "Panel1";
        vbox1.addChild(lbl1);
        dp.addChild(vbox1);

        var vbox2:VBox = new VBox();
        vbox2.label = "Tab 2";
        var lbl2:Label = new Label()
        lbl2.text = "Panel 2";
        vbox2.addChild(lbl2);
        dp.addChild(vbox2);
    }

    private function showTab(event:MouseEvent):void {
        makeVisible(true);
    }

    private function hideTab(event:MouseEvent):void {
        makeVisible(false);
    }

    private function makeVisible(vis:Boolean):void {
        VBox(dp.getChildAt(0)).visible = vis;
        VBox(dp.getChildAt(0)).enabled = vis;
        VBox(dp.getChildAt(0)).includeInLayout = vis;
    }
    ]]>
</fx:Script>
<s:VGroup>
    <s:TabBar id="tabNavigator" width="100%" height="100%" dataProvider="{dp}"/>
    <mx:ViewStack width="100%" height="100%" id="dp" borderStyle="solid"/>

    <s:Button click="showTab(event)" label="show Tab"/>
    <s:Button click="hideTab(event)" label="hide Tab"/>
</s:VGroup>

Any advice greatly received

Thanks

解决方案

This function will hide a tab at a particular index. If you do not have the includeInLayout then the tab disappears and leaves a hole.

private function setTabEnabled(index:int, enabled:Boolean):void {
    var theTab:UIComponent = tabNavigator.dataGroup.getElementAt(index) as UIComponent;
    if (theTab)
        theTab.visible = enabled;
        theTab.includeInLayout = enabled;
    }
}

这篇关于在Spark TabBar中隐藏选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:30