Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Returning from a child window not closing the child on Android?

Hi folks,

I was trying to understand how tabs are handled on Android, and I ran into a problem: hitting the back button would return to the previous window in the stack, but I was unable to activate the child again.

Here's the code:

// create tab group
var tabGroup = Titanium.UI.createTabGroup();

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 b = Ti.UI.createButton({title: "Press me"});
b.addEventListener("click", function () {
                       // if I don't .close(), this window can only be opened once
                       win3.close();
                       tab2.open(win3);
                       });
win2.add(b);

var win3 = Titanium.UI.createWindow({
    title:'new',
    backgroundColor:'#fff',
    tabBarHidden:true
});

var label3 = Titanium.UI.createLabel({
    color:'#999',
    text:'a new window',
    font:{fontSize:20,fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto'
});
win3.add(label3);


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

//open tab group
tabGroup.open();

When I added the .close() call in the code, it works now on both Android and the iPhone (it was only working on the latter before). Is this safe? Is it what I should be doing?

— asked April 25th 2010 by Damien Elmes
  • android
  • tab
  • window
0 Comments

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.