Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created June 24, 2011 21:29
Show Gist options
  • Select an option

  • Save jonalter/1045733 to your computer and use it in GitHub Desktop.

Select an option

Save jonalter/1045733 to your computer and use it in GitHub Desktop.
Open TabGroup from a home Window
var tabGroup;
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
layout: 'vertical',
exitOnClose: true,
navBarHidden: true
});
var createButton = Ti.UI.createButton({
title: "open",
top: 20,
height: 50,
width: 250,
});
createButton.addEventListener('click', function(e){
tabGroup = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
backgroundColor: 'blue'
});
var deleteButton = Ti.UI.createButton({
title: "close",
top: 20,
height: 50,
width: 250,
});
deleteButton.addEventListener('click', function(e){
tabGroup.close();
});
win1.add(deleteButton);
var win2 = Ti.UI.createWindow({backgroundColor: 'blue'});
// capture the back button being pressed for both tab windows
win1.addEventListener('android:back', function(e){
Ti.API.info('win1 BACK');
tabGroup.close();
});
win2.addEventListener('android:back', function(e){
Ti.API.info('win2 BACK');
tabGroup.close();
});
var tab1 = Ti.UI.createTab({ title: 'Tab 1', window: win1 });
var tab2 = Ti.UI.createTab({ title: 'Tab 2', window: win2 });
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.open();
});
win.add(createButton);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment