Image not getting displayed in Android Emulator

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

Hi,

I am stuck with a very basic problem. I am trying to insert an image into a window and it doesn't work.

My code is this:

var win = Ti.UI.createWindow({backgroundColor: '#ffffff'});

var wholeContent = Ti.UI.createImageView({

url: 'whole_con.jpg',
height: 'auto',
width: 'auto'

});

win.add(wholeContent); win.open();

'whole_con.jpg' is in the resources directory itself. Do you see any issues with it? However, I am not able to view it on the Android emulator. I did not test it with a device.

— asked 5 months ago by Shibili KR
6 Comments
  • I think I'm having the same problem.

    — commented 5 months ago by Stephen Tellis

  • So, there's a problem. I thought I was asking something silly.

    — commented 5 months ago by Shibili KR

  • There's actually a bug already filed that seems to describe the issue we're having. You can check your log and see if you get the same error.

    — commented 5 months ago by Stephen Tellis

  • Show 3 more comments

3 Answers

try

var wholeContent = Ti.UI.createImageView({
     image: 'whole_con.jpg'
});

— answered 5 months ago by Ed mediahack
answer permalink
6 Comments
  • Ed is right. url has been deprecated. In the online API docs, it says to use image instead.

    — commented 5 months ago by Shawn Lipscomb

  • I am sorry. That didn't work for me. Good tip anyways!

    — commented 5 months ago by Shibili KR

  • what versions of the Titanium Studio and SDK are you using?

    — commented 5 months ago by Ed mediahack

  • Show 3 more comments

Woa, an unexpected solution!!

I have made the before mentioned image in Adobe Photoshop. And then saved for the web. Now, I have opened it in IrfanView and saved as another jpeg picture. It worked when I used the new image. I am sure those headers Photoshop puts in your jpeg is not recognised by Titanium.

I was using Windows. Would love to know what happens in Mac

just save your image as a .png format you will get your solution

— answered 5 months ago by Mrugesh Bapotra
answer permalink
2 Comments
  • Tried that. It still doesn't work. I am sure I must be dong something silly.

    — commented 5 months ago by Shibili KR

  • Is this a "new" image? Clean and rebuid your project. Also, images should go in Resources/android/images/ (and then preferably in low, medium, and high subdirectories), and should be referenced as 'images/whole_con.jpg'.

    — commented 5 months ago by Shawn Lipscomb

Your Answer

Think you can help? Login to answer this question!