adding a label to view

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

I am trying to adda label to a view with no success what am i doing wrong?

var vi = Ti.UI.createView({
        backgroundColor : '#fff',
     })
 
image.addEventListener('touchend',function(e){
 
var label = Titanium.UI.createLabel({
    color:'#999',
    text:'I am Window 1',
    font:{fontSize:20,fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto'
});
 
        vi.add(label);
  win1.animate({
    duration : 500,
    view : vi, // this is the view to flip into...
    transition : Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
});
 
});
When I add a button to the view (vi) it works fine just i'm having no joy with the label. All I am trying to achieve is to add some text to the view.

— asked 8 months ago by Michael Sagar
2 Comments
  • where is image defined? is it having an impact on the view?

    — commented 8 months ago by Aaron Saunders

  • the full everything is as follows:

    Ti.UI.backgroundColor = 'white';
            var win1 = Ti.UI.createWindow();
            var image = Ti.UI.createImageView({
                image : data.rowData.identifier
            });
     
            var cButton = Titanium.UI.createButton({
            title : 'close',
            top : 10,
            width : 100,
            height : 40
        });
        cButton.addEventListener('click', function(event) {
            win1.close();
        });
         var vi = Ti.UI.createView({
            backgroundColor : '#fff',
         })
     
    image.addEventListener('touchend',function(e){
     
      var text = Ti.UI.createLabel({
     
    var label = Titanium.UI.createLabel({
        top : 10,  // set position?
        left : 10,  // set position?
        color:'#999',
        text:'I am Window 1',
        font:{fontSize:20,fontFamily:'Helvetica Neue'},
        textAlign:'center',
        width:'auto'
    });
     
            vi.add(label);
     
            //vi.add(text);
      win1.animate({
        duration : 500,
        view : vi, // this is the view to flip into...
        transition : Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
    });
     
    });
     
    vi.addEventListener('touchend',function(e){
     
    //TODO go back
     
    })
     
            win1.add(image);
            win1.add(cButton);      
            win1.open();
        }); 
     
     
     
     
        //Ti.UI.currentWindow.add(tableview);
        win.add(tableview);
        win.open();
    I this helps you under stand my problem. I find it very strange i can add a button and it will work but not a label.

    — commented 8 months ago by Michael Sagar

1 Answer

var label = Titanium.UI.createLabel({
    top : 10,  // set position?
    left : 10,  // set position?
    color:'#999',
    text:'I am Window 1',
    font:{fontSize:20,fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto'
});

Your Answer

Think you can help? Login to answer this question!