Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

setActiveTab not work in Android

Hi!

Property setActiveTab not work in applications using titanium mobile SDK 1.4.1.1 and compiling for Android, but works in 1.4.2 compiled from the git. The same happens with version 1.5.0 that I compiled today again from the git.

I'm trying to open a new window with three tabs after clicking on a TableViewRow and in the process try to set the index to setActiveTab (1) which is the second tab.

I'm trying to open a new window with three tabs after clicking on a TableViewRow and in the process try to set the index to setActiveTab (1) which is the second tab.

Below you will find an example of what I'm trying to do.

var tabGroup = Titanium.UI.createTabGroup();

var winAbout = Titanium.UI.createWindow({  
    title:'About'
});

var winDeal = Titanium.UI.createWindow({  
    title:'Deal'
});

var winMap = Titanium.UI.createWindow({  
    title:'Map'
});

var tabAbout = Titanium.UI.createTab({
  title: 'About',
  window: winAbout
});

var tabDeal = Titanium.UI.createTab({
  title: 'Deal',
  window: winDeal
});

var tabMap = Titanium.UI.createTab({
  title: 'Map',
  window: winMap
});

tabGroup.addTab(tabAbout);
tabGroup.addTab(tabDeal);
tabGroup.addTab(tabMap);

tabGroup.setActiveTab(1);
tabGroup.open();

I am hopeful that the final version of 1.5.0 it is fixed.

Yes, another thing in version 1.4.2 which seems to work when I use tabGroup.setActiveTab (1), other elements do not work the application does not work.

— asked October 7th 2010 by Guide Publishing Group
  • android
  • sdk
  • setactivetab
  • tabgroup
0 Comments

1 Answer

  • Providing the tab object as the parameter to setActiveTab() – instead of its index – solved this issue for me.

    tabGroup.setActiveTab(tabGroup.tabs[tabNum]);
    
    — answered March 27th 2011 by Jeff Schuler
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.