Titanium Community Questions & Answer Archive

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

switch between tab groups

I am new to titanium but know a bit of java so learning fast but struggling to figure out how to switch between tab groups.

You have probably seen this on many apps before where you have 4 tabs say and one of the tabs is [more tabs option] and switch you from one group tabs to another and back.

Dose anyone here have any idea hoe to achieve this i thought addeventlistener but did work for me and the docs a very vage.

would appreciate the help thanks

— asked September 22nd 2010 by Alan Young
  • addeventlistener
  • group
  • iphone
  • tab
0 Comments

2 Answers

  • var addTabButton = Titanium.UI.createButton({
    title:'Add/Remove Tab',
    top:10,
    height:40,
    width:200
    });

    // create button event listener
    addTabButton.addEventListener('click', function(e)
    {
    if (tabGroup.tabs.length == 5)
    {
    var win = Ti.UI.createWindow({title:'New Tab Window',barColor:'#000'});
    var newtab = Titanium.UI.createTab({
    icon:'../images/tabs/KS_nav_mashup.png',
    title:'New Tab',
    win:win
    });
    tabGroup.addTab(newtab);
    }
    else
    {
    var newtab = tabGroup.tabs[5];
    tabGroup.removeTab(newtab);
    }
    });

    — answered September 23rd 2010 by Varun Atluri
    permalink
    1 Comment
    • Hi dose this use a button to add more tabs or dose this code use an actual tab button to switch between tab?

      because this is what I have seen in other apps the end user would use one of the tab buttons to switch between tab groups.

      sorry in advance if I have miss read the code.

      do you know how the use a event listener on a tab ?

      — commented September 23rd 2010 by Alan Young
  • Solved it

    If anyone knows a better why please leave your solution posted :)

        tab4.addEventListener('focus',function(e)  {  
    
        tabGroup.close();
        tabGroup2.open();
    
        });
    
    
    
        tab8.addEventListener('focus',function(e)  {  
    
    
        tabGroup2.close();
        tabGroup.open();
    
         });
    
    — answered September 25th 2010 by Alan Young
    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.