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", 96, height:119, }); var caption = Titanium.UI.createLabel({ text:"Open the Specials Tab (Tap Here)", bottom:20, height:"auto", "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", "auto", height:"auto", bottom:20, textAlign:"center" }); win.add(label); //这不需要呼叫win.open() 当从 window打开tab