How to refresh a view ?

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

Hi,

I posted 4 weeks ago about some similar problem, with no answer, but i think my problem is easier to fix right now.

I simply want to refresh views on my window, when i use a createImageView or a createWebView, it work on the first time, but impossible to refresh the content if it change.

Can everyone please help me to understand what's wrong with my code ?

var win = Titanium.UI.currentWindow;
 
var onAir = Titanium.UI.createWebView({
        top: 70,
        left: 125,
        backgroundColor:'transparent',
        scalesPageToFit: false,
        touchEnabled: false,
        url: 'http://ellebore.getmyip.com:81/Ellebore/Morceau.aspx'
    }); 
 
var pubImage = Titanium.UI.createImageView({
    image: 'http://radio-ellebore.com/pubmobile.jpg',
    top: 235,
    backgroundColor:'transparent',
    height: 125,
    width: 250
});
 
win.addEventListener("open", function(){
    win.remove(pubImage);
    win.add(pubImage);
});
 
setInterval(function() {
    win.remove(onAir);
    win.add(onAir);
}, 1000);
- Application type : Mobile - Titanium SDK : 2.1.3. GA - Platform & version : iOS 6 - Device : iOS simulator, Androïd simulator, iPhone 4S - X-Code : Version 4.5.1 (4G1004) - Host Operating System : OSX 10.7.4 - Titanium Studio : Titanium Studio, build: 2.1.2.201208301612 (c) Copyright 2012 by Appcelerator, Inc. All rights reserved.

Build: jenkins-titanium-rcp-master-232 (origin/master) Date: 30 August 2012, 16:14:46

2 Answers

What are trying to say? you are simply removing and adding the same view.... you are not changing the url or the web view so how it is going to refresh..

setInterval(function() {
    win.remove(onAir);
    win.add(onAir);
}, 1000);

— answered 7 months ago by Ashish Nigam
answer permalink
2 Comments
  • in the image view does the url remains same for

    http://radio-ellebore.com/pubmobile.jpg
    and different different images...

    similar question for web view.....?

    — commented 7 months ago by Ashish Nigam

  • Yes, for testing, i was trying to switch between

    http://radio-ellebore.com/pubmobile.jpg
    and
    http://radio-ellebore.com/pubmobile3.jpg
    for see if the image in my app was changing, but it's frozen on the second one... I'm usually working on websites and i suppose that is different on apps.

    What i want to do is, for exemple, put an ad for a soda for 2 days using http://radio-ellebore.com/pubmobile.jpg and upload another ad 2 days later for a party using the same name on the same URL and make my app able to refresh the image when the source change.

    For the webview, it's a bit different because it's an "On Air" iframe who show the current artist and song, same problem, frozen on the first artist/song that was playing when i opened the app for the first time...

    — commented 7 months ago by Romain Gentilella

Thanks for your answer,

Actually, i don't really know how to manage refresh action. That's why i'm posting here, the views that i'm trying to refresh are supposed to be the sames:

  • For the image, it's the same URL, but we replace the source
  • For the webview, it's a changing text (artist and song from stream) and I want it to refresh when the source change, that's why I was trying to remove and add the same view...

I don't know why the view doesn't change when the source change... Is there something like a local cache ?

Your Answer

Think you can help? Login to answer this question!