您的位置:首页 > 其它

titanium开发教程-03-02自定义tab group

2012-03-17 12:44 387 查看






app.js

Titanium.UI.setBackgroundColor("#000");

var tabGroup = Titanium.UI.createTabGroup();

var toursWindow = Titanium.UI.createWindow({
title:"Tours",
backgroundColor:"#FFFFFF",
//因为 window 是封装在tab里, 它自动拥有一个 nav bar
// navbar 仅在 iOS里有样式
barColor:"#32411b"
});

var image = Titanium.UI.createImageView({
image:"images/exploreCalifornia.png",
width:96,
height:119,
});

var caption = Titanium.UI.createLabel({
text:"Open the Specials Tab (Tap Here)",
bottom:20,
height:"auto",
width:"auto",
textAlign:"center",
color:"#000000"
});

toursWindow.add(image);
toursWindow.add(caption);

var toursTab = Titanium.UI.createTab({
icon:"tours-tab.png",
title:"Tours",
window:toursWindow
});

var specialsWindow = Titanium.UI.createWindow({
title:"Specials",
backgroundColor:"#FFFFFF",
url:"specials.js"
});
var specialsTab = Titanium.UI.createTab({
icon:"specials-tab.png",
title:"Specials",
window:specialsWindow
});

caption.addEventListener("click", function(e){
tabGroup.setActiveTab(1);
});

tabGroup.addTab(toursTab);
tabGroup.addTab(specialsTab);

tabGroup.open();


 

 

specials.js

 

var win = Titanium.UI.currentWindow;
win.barColor = "#efe269";

var label = Titanium.UI.createLabel({
text:"Specials of the Day",
width:"auto",
height:"auto",
bottom:20,
textAlign:"center"
});

win.add(label);
//这不需要呼叫win.open() 当从 window打开tab
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: