0

我是新手,我看到了类似的问题,但很老,没有解决方案。我想要的只是在 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();
4

2 回答 2

0

目前没有办法在android上做到这一点:

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

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

http://sharesend.com/kbkasavo

希望这可以帮助

于 2012-12-11T13:02:40.313 回答
0

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

//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 窗口设置为选项卡。对所有选项卡重复此过程

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

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

  firstnavGroup.open(second);

我希望这能帮到您。

于 2011-10-05T06:28:11.113 回答