Skip to content

Instantly share code, notes, and snippets.

@hal-gh
Created November 10, 2010 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hal-gh/671380 to your computer and use it in GitHub Desktop.
Save hal-gh/671380 to your computer and use it in GitHub Desktop.
tabgroup close test
Ti.UI.setBackgroundColor('white');
var winRoot = Ti.UI.createWindow({
backgroundColor:'blue',
fullscreen: true,
title:'Tab 1'
});
var tabGroupMode = 1;
// click window to open tabgroup
winRoot.addEventListener('click', function(){
switch (tabGroupMode){
case 1:
var tabGroup1 = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
backgroundColor:'red',
title:'Tab 1'
});
var button1 = Ti.UI.createButton({
title:'Close TabGroup',
top:100,
height:100,
width:150
});
win1.add(button1);
button1.addEventListener('click', function(){
tabGroup1.close();
});
tabGroup1.addEventListener('close', function(){
Ti.API.info('tabGroup1 close event fired');
});
var tab1 = Ti.UI.createTab({
title:'Tab 1',
window:win1
});
var label1 = Ti.UI.createLabel({
text:'I am Window 1'
});
win1.add(label1);
var win2 = Ti.UI.createWindow({
backgroundColor:'green',
title:'Tab 2'
});
var label2 = Ti.UI.createLabel({
text:'I am Window 2'
});
win2.add(label2);
var tab2 = Ti.UI.createTab({
title:'Tab 2',
window:win2
});
tabGroup1.addTab(tab1);
tabGroup1.addTab(tab2);
tabGroup1.open();
tabGroupMode = 2;
break;
case 2:
var tabGroup2 = Ti.UI.createTabGroup();
var win3 = Ti.UI.createWindow({
backgroundColor:'olive',
title:'Tab 3'
});
var button2 = Ti.UI.createButton({
title:'Close TabGroup',
top:100,
height:100,
width:150
});
win3.add(button2);
button2.addEventListener('click', function(){
tabGroup2.close();
});
tabGroup2.addEventListener('close', function(){
Ti.API.info('tabGroup1 close event fired');
});
var tab3 = Ti.UI.createTab({
title:'Tab 3',
window:win3
});
var label3 = Ti.UI.createLabel({
text:'I am Window 3'
});
win3.add(label3);
var win4 = Ti.UI.createWindow({
backgroundColor:'teal',
title:'Tab 4'
});
var label4 = Ti.UI.createLabel({
text:'I am Window 4'
});
win4.add(label4);
var tab4 = Ti.UI.createTab({
title:'Tab 4',
window:win4
});
tabGroup2.addTab(tab3);
tabGroup2.addTab(tab4);
tabGroup2.open();
tabGroupMode = 1;
break;
}
});
winRoot.open();
@Umaid1
Copy link

Umaid1 commented Jul 18, 2012

tabGroup.close() doesnt work on Android, please suggest alternate solution as my application is shutting down after showing black screen.

355)] jsValueToJavaObject returning null
[ERROR]TiBaseActivity( 355) [8679,42904] Layout cleanup.
[WARN][InputManagerService( 61)] Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@44f5a660 (uid=10040 pid=355)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment