Titanium Community Questions & Answer Archive

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

imageView load event does not fire after image property is changed

Hi,
I am trying to display a loading throbber until all of the images are loaded on a particular screen. The image views are created with empty 'image' properties, and this is filled in later with a URL. The 'load' event is not firing when the remote image is loaded. This Post implies that the load event only fires on images where the image property has not been updated. Is this the case? Do I need to dynamically create the imageViews each time? I load different images to the same view periodically, so that would be kinda messy. Any ideas?

Relevant code (pulled from multiple places):

var imageView = Titanium.UI.createImageView({
    width:100,
    top:5,
    left:30,
    borderColor:'#999',
    borderWidth:1
});

imageView.addEventListener('load', function() {imageLoaded();});
//^^^ this never fires^^^

imageView.image = "http://the.image.url";

Thanks for all your help.

— asked November 10th 2010 by Nate Allen
  • android
  • event
  • image
  • load
  • mobile
2 Comments
  • I am very much in need of this event as well, if it is not working how can we know when a ImageView was loaded? Is there another way?

    — commented November 27th 2010 by Antonio Silveira
  • it seems to be firing if your image view is added to a window but you have to open your window first… which defeats the point.

    — commented June 8th 2011 by Ken Gerts

4 Answers

  • On Android the load event doesn't fire at all. There is a bug. (more details here: android load event bug

    On iPhone if the imageView has touchEnabled set to false, then the load event doesn't fire. (more details here:
    iphone imageView load event bug

    — answered March 16th 2011 by Daniel Tome
    permalink
    0 Comments
  • i m having the same problem I think
    http://developer.appcelerator.com/question/120733/splash-screen-image-load-question

    — answered June 8th 2011 by Ken Gerts
    permalink
    0 Comments
  • i use xhr to load the url manually, and set the image during onLoad. kitchen sink's xhr_binary.js illustrated this very well.

    — answered October 21st 2011 by Jorge Chang
    permalink
    0 Comments
  • it might be completely irrelevant but try to change your syntax, try to use this:

    imageView.addEventListener('load', imageLoaded);

    ofc i assume that you got defined imageLoaded function in the same scope:

    function imageLoaded(e) { … }

    — answered February 12th 2011 by gondo gondo
    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.