Search code examples
androidimagetitaniumappcelerator

Appcelerator show an image


Greetings,

I'm trying to simply display an image using Appcelerator on Android.

I don't understand why it won't work.

Here is my code:

var back=Titanium.UI.createImageView({
 url:'images/back.png'
});

win.add(back);

I've also tried putting the image inside a view:

var view = Titanium.UI.createView({
   borderRadius:10,
   backgroundColor:'red',
   left:10,
     right:10
});
var back=Titanium.UI.createImageView({
 url:'images/back.png'
});
view.add(back);
win.add(view);

I'm totally stuck and am hoping someone can point me in the right direction here.

Many thanks in advance,


Solution

  • I got it working as follows:

    var back_fn=Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'images/back.png');
    var back=Titanium.UI.createImageView({
        image:back_fn,
        top:10,
        right:10
    });
    win.add(back);
    

    Thanks for all the responses guys,