As a newcomer, I have come across similar questions but they are quite old and do not provide a solution. What I want to achieve is to open a new window inside the activeTab while preserving the tab group. However, my code only opens a new window that takes up the entire screen without maintaining the tabs. I would really appreciate it if someone could confirm if this can be done at all. Perhaps using views somehow... And it should work for Android as well. Below is the code snippet:
// Setting background color of master UIView (when no windows/tab groups are present)
Titanium.UI.setBackgroundColor('#000');
// Creating the tab group
var tabGroup = Titanium.UI.createTabGroup();
// Creating base UI tab and root window
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
// Creating controls tab and root window
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win2.add(label2);
var data = [
{title:"Sample 1",color:'black',hasChild:true,font:{fontSize:16,fontWeight:'bold'}},
{title:"Sample 2",color:'black',hasChild:true,font:{fontSize:16,fontWeight:'bold'}}
];
var table = Titanium.UI.createTableView({
data:data,
separatorColor: '#ccc',
backgroundColor:'#fff'
});
win1.add(table);
// Table view event listener
table.addEventListener('click', function(e) {
var win = Titanium.UI.createWindow({
url:'windows/main.js' // creating a new window
});
// This line opens the newly created window in full screen mode without retaining the original tab group
tabGroup.activeTab.open(win,{animated:true});
});
// Adding tabs
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
// Opening the tab group
tabGroup.open();