Titanium Community Questions & Answer Archive

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

Label text cannot be set unless initialized first...

Just noticed this earlier today..

if I have a label, with no 'text' attribute.. I am unable to later update that attribute..

label.text = 'blah' will do nothing.. no error. .or anything…

but if I at least have createLabel({text:''})

then label.text = 'blah' will work as expected..

just an fyi.. I'm using the continuous builds..

— asked December 3rd 2010 by Critter
  • createlabel
2 Comments
  • When you post a question, please always state your mobile platform and Titanium SDK. The easiest way is simply to include this information in the question tags.

    — commented December 3rd 2010 by Paul Dowsett
  • In this case, by Ti SDK, I mean the version/branch of the continuous build.

    — commented December 3rd 2010 by Paul Dowsett

2 Answers

  • Accepted Answer

    Critter

    I have tested your observation on android continuous builds 1.4.X and 1.5.X using the following code, and they don't exhibit the issue.

    var win1 = Ti.UI.createWindow({  
        backgroundColor:'white',
        navBarHidden:false,
        title:'This is window 1'
    });
    
    var view1 = Ti.UI.createView({
        backgroundColor:'blue',
        width:180
    });
    
    var label = Ti.UI.createLabel({
        backgroundColor:'red'
    });
    
    view1.add(label);
    win1.add(view1);
    
    win1.open();
    label.text = 'this is my label';
    

    Would you try this code on your system, to see if there really is a bug?

    Which mobile platform are you using?

    If you think it's an issue with your code, you could post it and I'm sure someone could help.

    Cheers

    — answered December 3rd 2010 by Paul Dowsett
    permalink
    0 Comments
  • Yeah.. not sure what the deal is.. your code works. so it's not a bug..

    My code works if I set the text to '' when I create the labels.. shrug

    for now it works. I'll jump more into it later..

    thanks for the reply..

    — answered December 3rd 2010 by Critter
    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.