Open several windows in same tab? (Android)

You must Login before you can answer or comment on any questions.

Hi.

I have a tabgroup with 4 tabs in a tabgroup.

In each of those tabs i have like 3-4 links to new windows and so on....

How can i open those windows and stay in the same tab?

If i use

tab1.add(new_win);
new_win.open():
I get: "Tab1 not defined" error

And if i use

Titanium.UI.currentTab(new_win);
i get "CurrentTab is not a function".

So how do i do it?

I open all my windows with

modal:true, fullscreen      : true,
    navBarHidden    : true
Would that matter?

Thanx.

1 Answer

Ti.UI.currentTab is definitely not a function. I think it is supposed to be a reference to the current tab. But AFAIK, it doesn't work anyway. If it did work, you could do this:

Ti.UI.currentTab.open (new_win);
But since it doesn't work, I think you should forget about trying to use it. You need to keep track of the tabGroup in a global variable and call getActiveTab() on it. Then call open() on that active tab.

Please see my post here. In that post, I present a "TabGroup Window Manager" that abstracts away the cross-platform differences and the need to keep track of the tab group. Note that you MUST use a pure CommonJS module approach in your app (you should be anyway) for my code to work.

— answered 12 months ago by Jason Priebe
answer permalink
8 Comments
  • Ok sounds legit!

    Just to be sure that we are on the same page here.

    I will make my tabgroup as usual like this?

    var TGWM = require ('/TGWM');
    var tgwm = new TGWM ();
    var tabgroup = tgwm.createTabGroup ();
     
     
    var win1 = Titanium.UI.createWindow({  
        url: 'start.js',
        backgroundColor:'#000',
        fullscreen: true,
        navBarHidden    : true
    });
    var tab1 = Titanium.UI.createTab({  
        icon: 'Airplane.png',
        title:'Hem',
        window:win1
    });
     
     
    var win2 = Titanium.UI.createWindow({  
        url: 'gallery.js',
        backgroundColor:'#000'
    });
    var tab2 = Titanium.UI.createTab({  
       icon: 'Chat.png',
       title:'Galleri',
       window:win2
    });
    tabGroup.addTab(tab1);  
    tabGroup.addTab(tab2);  
     
    tabGroup.open();
    And in my windows i will open the new windows with the
    var TGWM = require ('/TGWM');
     
    TGWM.openWindow (w);

    Will i open my new (sub)windows modal?

    I have put the TGWM in place and changed my app.js to this but i get a runtime error on the splashscreen saying " Object [object Object] has no method 'createTabGroup'

    I am not using CommonJS modules but on the other hand i dont 'include' anything either...

    Any thoughts on the error?

    Thanx.

    — commented 12 months ago by Richard Harrysson

  • Ok sorry i had read to little as usual.....

    So you´re saying that i cant reference my windows with url: 'foo.js', but if i require them then it would work?

    — commented 12 months ago by Richard Harrysson

  • Ok. Now i have changed my code in app.js to

    var win1 = require('start');
    And in start.js i have changed this
    var win = Ti.UI.currentWindow;
    To
    function start() {
    var win = Ti.UI.createWindow();
     
    ///////Things that happens in my window /////
     
    return self;
    };
     
    module.exports = start;
    Am i thinking in the right directions here or am i just in over my head?

    — commented 12 months ago by Richard Harrysson

  • Show 5 more comments

Your Answer

Think you can help? Login to answer this question!