下面是我的选项卡式条码:
<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>当我点击一个选项卡时,如何确保视图与按下的按钮相对应--我知道如何使用钛,而不是合金。
干杯。
发布于 2014-09-18 03:53:41
我昨天也遇到了同样的问题。我确信肯定有更好的方法,但我在文档中看不到任何东西,这是我的解决方案:
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版本上,你不需要自己处理点击。)
https://stackoverflow.com/questions/25834976
复制相似问题