Titanium Community Questions & Answer Archive

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

Subwindow - Android

My question is how to create a subwindow for android in windows.Android does not like the win1.add(subwin); command. It works for labels.

Please find me solution to solve the problem.

Thanks and Regards,
Venkatesan.R

— asked November 30th 2010 by venkatesan ramdoss
  • android
  • subwindow
0 Comments

2 Answers

  • Accepted Answer

    venkatesan

    The problem you have is that you cannot add a window to another window, but you can open one from a window.

    Drop this code into your app.js, and hopefully you will see what I mean:

    var win1 = Ti.UI.createWindow({  
        backgroundColor:'red',
        navBarHidden:false,
        title:'this is window 1'
    });
    
    var view1 = Ti.UI.createView({
        backgroundColor:'green'
    });
    win1.add(view1);
    
    var button = Ti.UI.createButton({
        title:'open win2'
    });
    view1.add(button);
    
    button.addEventListener('click', function(){
        var win2 = Ti.UI.createWindow({  
            backgroundColor:'blue',
            navBarHidden:false,
            title:'this is window 2'
        });
    
        var view1 = Ti.UI.createView({
            backgroundColor:'yellow'
        });
    
        win2.open();    
    });
    
    — answered November 30th 2010 by Paul Dowsett
    permalink
    0 Comments
  • AFAIK, windows exist on their own, not as children of anything, particularly each other. You can create multiple windows and hide/show them as needed. But, you can't do as you were trying to do. If you don't need anything especially window-ish, could you use a view for your subwin?

    — answered November 30th 2010 by Tim Poulsen
    permalink
    0 Comments
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.