GitHub Issue | n/a |
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-03-23T23:43:11.000+0000 |
Affected Version/s | Release 3.1.3, Release 3.2.0, Release 3.2.1 |
Fix Version/s | 2014 Sprint 06, 2014 Sprint 06 SDK, Release 3.2.3, Release 3.3.0 |
Components | Android |
Labels | module_tabgroup, qe-testadded, supportTeam |
Reporter | Mostafizur Rahman |
Assignee | Biju pm |
Created | 2014-03-02T06:30:35.000+0000 |
Updated | 2014-03-26T06:13:24.000+0000 |
Problem Description
setActive method is not working in tabgroup. It displays an error “Invalid tab index”.
Test Environment
Mac OX X 10.9.2
Ti SDK 3.1.3.GA, 3.2.0.GA, 3.2.1.GA
Ti CLI 3.2.1
Android 2.3.3
Test Code
var win1 = Ti.UI.createWindow({
title : 'Win 1'
});
var button = Ti.UI.createButton({
color : '#000',
style : Ti.UI.iPhone.SystemButtonStyle.BORDERED,
title : 'Set Active Tab 1'
});
button.addEventListener('click', function(e) {
tabGroup.setActiveTab(1);
//Ti.API.info('****************** activeTab: ' + tabGroup.activeTab);
});
win1.add(button);
var tab1 = Ti.UI.createTab({
icon : 'KS_nav_ui.png',
title : 'Tab 1',
window : win1
});
var win2 = Ti.UI.createWindow({
title : 'Win 2'
});
var tab2 = Ti.UI.createTab({
icon : 'KS_nav_views.png',
title : 'Tab 2',
window : win2
});
var tabGroup = Ti.UI.createTabGroup({
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
/*
tabGroup.addEventListener('open', function(e) {
tabGroup.setActiveTab(1);
Ti.API.info('****************** activeTab: ' + tabGroup.activeTab);
});
*/
tabGroup.setActiveTab(1);
tabGroup.open();
//Ti.API.info('********************* activeTab: ' + tabGroup.activeTab);
Step to reproduce
Create ti sample project in titanium classic
Update app.js file with sample code
Run on android device/emulator
Check console log for error
Expected Result
Tab 2 will select when app is run.
Actual result
Tab 1 selected.
Logs
[ERROR] : TabGroupProxy: (KrollRuntimeThread) [390,390] Invalid tab index.
Workaround Code
var win1 = Ti.UI.createWindow({
title : 'Win 1'
});
var button = Ti.UI.createButton({
color : '#000',
style : Ti.UI.iPhone.SystemButtonStyle.BORDERED,
title : 'Set Active Tab 1'
});
button.addEventListener('click', function(e) {
tabGroup.setActiveTab(1);
//Ti.API.info('****************** activeTab: ' + tabGroup.activeTab);
});
win1.add(button);
var tab1 = Ti.UI.createTab({
icon : 'KS_nav_ui.png',
title : 'Tab 1',
window : win1
});
var win2 = Ti.UI.createWindow({
title : 'Win 2'
});
var tab2 = Ti.UI.createTab({
icon : 'KS_nav_views.png',
title : 'Tab 2',
window : win2
});
var tabGroup = Ti.UI.createTabGroup({
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addEventListener('open', function(e) {
tabGroup.setActiveTab(1);
Ti.API.info('****************** activeTab: ' + tabGroup.activeTab);
});
//tabGroup.setActiveTab(1);
tabGroup.open();
//Ti.API.info('********************* activeTab: ' + tabGroup.activeTab);
Thanks
PR:- https://github.com/appcelerator/titanium_mobile/pull/5219
Back port PR: https://github.com/appcelerator/titanium_mobile/pull/5511
Verified the fix using the environment as Device : Google Nexus 5, Android Version: 4.4.2 SDK: 3.2.3.v20140324164913 CLI version : 3.2.1 OS : MAC OSX 10.9.2 Alloy: 1.3.1 ACS: 1.0.14 npm:1.3.2 Appcelerator Studio, build: 3.2.3.201403190645 titanium-code-processor: 1.1.0 XCode : 5.1