首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tabbedBar,显示不同视图的钛

tabbedBar,显示不同视图的钛
EN

Stack Overflow用户
提问于 2014-09-14 15:37:32
回答 1查看 136关注 0票数 0

下面是我的选项卡式条码:

代码语言:javascript
复制
<Alloy>
    <Window class="container">
        <Label id="label" onClick="doClick">Hello, World</Label>
                <TabbedBar id="bb1" platform="ios" backgroundColor="#369" top="50" height="25" width="200">

                    <!-- The Labels tag sets the TabbedBar.labels property. -->
                    <Labels>

                        <!-- Specify text with node text or the title attribute. -->
                        <!-- Can also specify the enabled, image and width attributes. -->

                        <Label>One</Label>
                        <Label>Two</Label>
                        <Label>Three</Label>

                    </Labels>

                    <!-- Place additional views for the TabbedBar here. -->
                    <Views>
                    <View backgroundColor='red'>1</View>
                    <View>2</View>
                    <View><Label>Does this work!</Label></View>
                    </Views>

                </TabbedBar>
    </Window>
</Alloy>

当我点击一个选项卡时,如何确保视图与按下的按钮相对应--我知道如何使用钛,而不是合金。

干杯。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-18 03:53:41

我昨天也遇到了同样的问题。我确信肯定有更好的方法,但我在文档中看不到任何东西,这是我的解决方案:

代码语言:javascript
复制
var animation = require('alloy/animation');

var previousIndex = $.tabbedBar.getIndex();
$.tabbedBar.addEventListener('click', function(){

    var currentIndex = $.tabbedBar.getIndex();
    var viewArr = [];

    viewArr[0] = $.view1;
    viewArr[1] = $.view2;
    viewArr[2] = $.view3;

    animation.crossFade(viewArr[previousIndex], viewArr[currentIndex], 700)

    previousIndex = currentIndex;

});

编辑:(如果你不知道,在Android上有一个模块可以给你提供类似的功能:https://github.com/ricardoalcocer/viewpager,但是检查原始回购中的问题#5,因为你必须将它合并到任何构建中。在Android版本上,你不需要自己处理点击。)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25834976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档