本文介绍了Flex - 如何制作选项卡式面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有 3 个类别的按钮,我想要一个选项卡式面板,我可以使用它在 3 个类别之间切换,例如 示例:

My app has 3 categories of buttons, I want to have a tabbed panel I can use to switch between the 3 categories like in this example:

我的应用程序是一个移动应用程序,所以我不能使用 mx 组件.当我尝试搜索移动标签式导航等时,我只提供了 viewnavigator 示例.

My app is a mobile app though so I can't use mx components. When I try searching for mobile tabbed navigation etc., I come up with only viewnavigator examples.

推荐答案

对于移动选项卡式应用程序,您只需使用 TabbedViewNavigatorApplication 类:

For a mobile tabbed application, you simply use the TabbedViewNavigatorApplication class:

第一种方法

您的视图只是使用 作为根注释的 MXML 组件.

Your views are simply MXML components that use <s:View> as the root note.

阅读您的评论后,我发现您希望在视图中使用标签栏.在普通 Flex 中,您可以使用 TabBar 并将其附加到 ViewStack,但 ViewStack 在移动设备中不可用...因此您可以即兴发挥使用状态,将 TabBar 绑定到状态名称并根据状态隐藏/显示面板.下面是一个例子:

Reading your comments, I see that you want a tabbed bar within your view. In normal Flex, you would use a TabBar and attach it to a ViewStack but ViewStack is not available in mobile... so you can improvise using states, binding a TabBar to the names of the states and hide/show panels based on state. Here is an example:

第二种方法*

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">

    <s:layout>
        <s:VerticalLayout />
    </s:layout>

    <s:states>
        <s:State name="One" />
        <s:State name="Two" />
        <s:State name="Three" />
    </s:states>

    <s:TabBar id="tabBar" width="100%"
              change="currentState = tabBar.dataProvider[event.newIndex]">
        <s:ArrayCollection>
            {states.map(function(x) { return x.name; }) }
        </s:ArrayCollection>
    </s:TabBar>

    <s:Group includeIn="One" width="100%" height="100%">
        <s:Label text="Tab One" />
    </s:Group>

    <s:Group includeIn="Two" width="100%" height="100%">
        <s:Label text="Tab Two" />
    </s:Group>

    <s:Group includeIn="Three" width="100%" height="100%">
        <s:Label text="Tab Three" />
    </s:Group>

</s:View>

但是,您可能仍希望保留移动标签导航功能,但仅限于一种特定视图.您可以在视图中包含 TabbedViewNavigator 而不是使用 TabbedViewNavigatorApplication.

BUT, you might still want to keep the mobile tab navigation functionality but only for one particular view. You can include a TabbedViewNavigator inside of your view instead of using a TabbedViewNavigatorApplication.

第三种方法

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">

    <s:TabbedViewNavigator width="100%" height="100%">
        <s:ViewNavigator label="1st Tab" width="100%" height="100%"
                         firstView="views.FirstTabView"/>
        <s:ViewNavigator label="2nd Tab" width="100%" height="100%"
                         firstView="views.SecondTabView"/>
        <s:ViewNavigator label="3rd Tab" width="100%" height="100%"
                         firstView="views.ThirdTabView"/>
    </s:TabbedViewNavigator>

</s:View>

您将获得一个嵌套的操作栏",因此您可以通过设置 actionBarVisible="false"

You will get a nested "Action Bar" so you can disable the nested one in each of the tab views by setting actionBarVisible="false"

希望这有帮助!!!!

这篇关于Flex - 如何制作选项卡式面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:00