flex中TabBar、ButtonBar以及ViewStack

flex中实现标签页的方法:

方法1:

<s:TabBar dataProvider="{myViewStack}" top="0" x="5"/>

<mx:ViewStack id="myViewStack" creationPolicy="all" styleName="tabViewStack"
                       width="100%" height="100%" top="22" change="costViewStack_changeHandler(event)">         
            <s:NavigatorContent id="costTabel" label="费用列表" height="100%" left="10">              
                <!--显示必要的界面-->
            </s:NavigatorContent>             
            
            <s:NavigatorContent id="costReport" label="报表信息" height="100%" left="10">
                <s:BorderContainer id="viewerGroup" width="100%" height="100%" borderVisible="false">                  
                    <s:Label text="显示报表界面" top="35"/>
                </s:BorderContainer>
            </s:NavigatorContent>        

</mx:ViewStack>

效果如下:

如果把TabBar用ButtonBar替换掉之后,效果如下

根据效果不同,可以选择适当的实现方式,如果需要实现特定的效果,则通过itemRender实现自定义效果。

ButtonBar是基于List的控件,不要被它的外表所误导。

ButtonBar和TabBar的集成结构如下:

ButtonBar ---ButtonBarBase--ListBase

TabBar --ButtonBarBase--ListBase

所以可以使用dataProvider提供数据,如下

<s:ButtonBar>
    <s:ArrayCollection>
        <fx:String>Button One</fx:String>
        <fx:String>Button Two</fx:String>
        <fx:String>Button Three</fx:String>
        <fx:String>Button Four</fx:String>
    </s:ArrayCollection>
</s:ButtonBar>


方法2:

<mx:TabNavigator id="myViewStack" creationPolicy="all" styleName="tabViewStack"
                       width="100%" height="100%" top="22" change="costViewStack_changeHandler(event)">         
            <s:NavigatorContent id="costTabel" label="费用列表" height="100%" left="10">
                <s:Label text="显示表格界面" top="35"/>    
            </s:NavigatorContent>             
            
            <s:NavigatorContent id="costReport" label="报表信息" height="100%" left="10">
                <s:BorderContainer id="viewerGroup" width="100%" height="100%" borderVisible="false">
                    <s:Label text="显示报表界面" top="35"/>
                </s:BorderContainer>
            </s:NavigatorContent>         
</mx:TabNavigator>

使用TabNavigator替换ViewStack,TabNavigator继承自ViewStack,但是它会自带两个选项卡,而ViewStack则需要配合TabBar或者ButtonBar来实现,效果如下:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值