Refresh Image in ImageView
Another basic question: I try to refresh a image in an ImageView. I found this posting:
support.appcelerator.net
This doesn't work for me. I can't set a new image.url.
Here is my code:
var picRandom = 0;
var myImageView = Ti.UI.createImageView({
url:'http://anyurl.com/anypicture.jpg',
width:480,
height:320,
top:0
});
myView.add(myImageView);
var myImageViewUrl = 'http://anyurl.com/anypicture.jpg';
function doLoadData(){
myImageView.url = myImageViewUrl;
}
myImageView.addEventListener('singletap', function(e){
doLoadData();
});
but doLoadData does nothing. I altered the image url, but no matter what I do the myImageView stays the same…
Thanks in advance!
5 Answers
-
I managed to refresh the image like this:
img.url = 'myimage.jpg';
img.hide();
img.show(); -
Did you mean to add myImageView to myView? If you instead do Ti.UI.currentWindow.add(myImageView) what you're trying to do seems to work okay for me.
-
Yeah I put the whole ImageView in another View and now it works fine.
But every time I reload my image there is some loading image (a blue wave). How can I remove this image?
Edit:
preventDefaultImage removes this loading image, but there is still an opacity fade… how do i get rid of those? -
I don't believe there's a way to prevent that right now. A word around might be to toggle the visibility to false and listen for the load event, then make the image visible again. That won't have the animation.
Hmmm…just tried that and the load event doesn't seem to fire, so never mind that option for now.
Another option might would be to use a webView instead of an imageView which won't have that same animation.
-
I'm trying to do something very similar. Did you ever get this resolved?