Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16530] Android: setActive tab is not working

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-03-23T23:43:11.000+0000
Affected Version/sRelease 3.1.3, Release 3.2.0, Release 3.2.1
Fix Version/s2014 Sprint 06, 2014 Sprint 06 SDK, Release 3.2.3, Release 3.3.0
ComponentsAndroid
Labelsmodule_tabgroup, qe-testadded, supportTeam
ReporterMostafizur Rahman
AssigneeBiju pm
Created2014-03-02T06:30:35.000+0000
Updated2014-03-26T06:13:24.000+0000

Description

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

Comments

  1. Biju pm 2014-03-19

    PR:- https://github.com/appcelerator/titanium_mobile/pull/5219
  2. Pedro Enrique 2014-03-24

    Back port PR: https://github.com/appcelerator/titanium_mobile/pull/5511
  3. Paras Mishra 2014-03-25

    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

JSON Source