Search code examples
imageviewtitaniumtitanium-alloyappcelerator-mobile

How to load remote images using Titanium Alloy


So I've been trying to load a remote image using titanium, here's a snippet that I'm using, but it always shows the default image. Any clue what I am doing wrong, I'm sorry it's a naive question

here's my view

<View id="image">

</View>    

and my controller

userImage = Ti.UI.createImageView({
            id : "userImage",
            image : "http://graphics.ucsd.edu/~henrik/images/imgs/face_bssrdf.jpg",
            width : 90,
            center:0,
            height : 90,
        });
    $.image.add(userImage);

had to upgrade the sdks was buggy at 4.0.0.RC


Solution

  • The following code works fine for me with 4.0.0.GA and 4.1.0.GA:

    var win = Ti.UI.createWindow({
        backgroundColor: 'green'
    });
    
    var userImage = Ti.UI.createImageView({
        id: "userImage",
        image: "http://graphics.ucsd.edu/~henrik/images/imgs/face_bssrdf.jpg",
        width: 90,
        center: 0,
        height: 90,
    });
    
    win.add(userImage);
    
    win.open();
    

    screenshot