activeTab.open()新窗口不保留选项卡

(Titanium mobile, Android) activeTab.open() new window is not preserving tabs

本文关键字:保留 选项 open 新窗口 activeTab 窗口      更新时间:2023-09-26

我是新来的,我看到过类似的问题,但很老,没有解决方案。所有我想要的是打开activeTab内的新窗口,并保留标签组。不幸的是,我的代码打开新窗口,但不保持标签,窗口只是全屏。如果有人能确认我想要实现的是可能的,我会非常感激。也许在某种程度上……再一次,它应该适用于android。下面是代码:

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create 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
});

//
// create 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);
// create table view event listener
table.addEventListener('click', function(e)
{
        var win = Titanium.UI.createWindow({
            url:'windows/main.js'       
        });
        // this simply opens the new created window but full screen and without original tab group.
         tabGroup.activeTab.open(win,{animated:true});

});
//
//  add tabs
//
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  

// open tab group
tabGroup.open();

目前在android上没有办法这样做:

http://developer.appcelerator.com/question/145471/application-with-strange-navigation-how-to-implement-it回答- 252500

在这里你可以找到我的解决方案的演示…

http://sharesend.com/kbkasavo

希望能有所帮助

您必须为每个选项卡窗口创建导航组。例如

//Here's the first window...
var first = Ti.UI.createWindow({
    backgroundColor:"#fff",
    title:"My App"
});

接下来,我们将创建一个NavigationGroup。这是一个只支持iphone的组件,它控制着一堆窗口(参考文档)——我们将把第一个窗口传递给它,作为它最初的可视窗口:

    //Here's the nav group that will hold them both...
    var firstnavGroup = Ti.UI.iPhone.createNavigationGroup({
        window:first
    });


    //This is the main window of the application
    var mainfirst = Ti.UI.createWindow();
    mainfirst.add(firstnavGroup);

然后将这个mainfirst窗口传递给tab。对所有选项卡

重复此过程

现在当你需要打开新窗口时,你必须写

var second = Ti.UI.createWindow({
  background:"#fff",
  title:"Child Window"
});
  firstnavGroup.open(second);