Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3628] Android: setActiveTab does not switch tabs if child window opened in tab

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2011-04-19T18:54:35.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sn/a
ComponentsAndroid
Labels1.6.1, android, rplist, setactivetab, tabGroup
ReporterJon Alter
AssigneeDon Thorp
Created2011-04-19T18:24:31.000+0000
Updated2017-03-09T23:18:44.000+0000

Description

If you open a window inside of a tab and then call setActiveTab, the tab switches as it should behind the open window. You never see this because the open window is not hidden in the process. This can be seen in KitchenSink 'Base UI'>'Tab Groups'>'Set Active Tab(either)'. Step 1: run the code below Step 2: click the 'Open Child Window' button Step 3: click the 'Tab 2' button Step 4: notice that nothing happens Step 5: hit the back button Step 6: notice that the tab is changed
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();

//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var button1 = Ti.UI.createButton({
	title: 'Open child window'
});
button1.addEventListener('click', function(e){
	childWin = Titanium.UI.createWindow({
		title:'Tab 1 Child',
		backgroundColor:'#fff'
	});
	
	var button2 = Ti.UI.createButton({
		title: 'Tab 2'
	});
	button2.addEventListener('click', function(e){
		tabGroup.setActiveTab(tab2);
	});
	childWin.add(button2);
	
	Titanium.UI.currentTab.open(childWin,{animated:true});
});
win1.add(button1);

var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win2.add(label2);

//
//  add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);  

// open tab group
tabGroup.open();

Tested On

Android 2.2 Emulator, TiSDK 1.6.1

Associated Helpdesk Ticket

http://support-admin.appcelerator.com/display/UUP-44372-885

Comments

  1. Jon Alter 2011-04-19

    Workaround

    If you close the open window(s) when you setActiveTab it will act as expected.
  2. Jon Alter 2011-04-19

    This is default android behavior. You must close the open window when you setActiveTab.
  3. Lee Morris 2017-03-09

    Closing ticket as invalid.

JSON Source