Is there a way to manage tab order in a tab group?
As per the title, is there a way to manage the tab order of tabs in a tabGroup aside from the order that addTab() is called? For example, if you're later adding a new tab to an already established tabGroup and you want to ensure that it's somewhere besides at the end, how do you accomplish that?
Thanks.
1 Answer
-
Hello everyone,
I searched for this solution everywhere, but as I found I broke a little
the head and did work. I'm going like, to facilitate those who need// Create Tab Group var tabGroup = Ti.UI.createTabGroup(); // Create Windows var win1 = Ti.UI.createWindow(); var win2 = Ti.UI.createWindow(); var win3 = Ti.UI.createWindow(); var win4 = Ti.UI.createWindow(); var win5 = Ti.UI.createWindow(); var win6 = Ti.UI.createWindow(); var win7 = Ti.UI.createWindow(); // Create Tabs var tab1 = Ti.UI.createTab({ id:1, window:win1 }); var tab2 = Ti.UI.createTab({ id:2, window:win2 }); var tab3 = Ti.UI.createTab({ id:3, window:win3 }); var tab4 = Ti.UI.createTab({ id:4, window:win4 }); var tab5 = Ti.UI.createTab({ id:5, window:win5 }); var tab6 = Ti.UI.createTab({ id:6, window:win6 }); var tab7 = Ti.UI.createTab({ id:7, window:win7 }); // Save Tab order on Pause/Exit Ti.App.addEventListener('pause', function(e){ for(i=0;i<7;i++){ Ti.App.Properties.setString('TB'+i,tabGroup.tabs[i].id); } }); // Load Tabs in Order for(i=0;i<7;i++){ // Try to get saved values for Tab Order k = Ti.App.Properties.getString('TB'+i); if(k==null){ // If don't have saved, populate in Designer order eval('tabGroup.addTab(tab'+(i+1)+');'); }else{ // if have saves, populate eval('tabGroup.addTab(tab'+k+');'); } } // Set First Tab Active tabGroup.setActiveTab(0); // Open tabGroup.open();