Activity Indicatior WebView
Hi all,
I was just wondering if it is possible to display activity indicator before the a remote page loads onto a webview? my code so far has been
var webview = Titanium.UI.createWebView({ url: Titanium.UI.currentWindow.param,backgroundColor:'#000' });
Titanium.UI.currentWindow.add(webview);
var actInd = Titanium.UI.createActivityIndicator({
height: 50,
width: 10
});
webview.beforeload = function() {
Titanium.UI.currentWindow.add(actInd);
actInd.show();
};
webview.onload=function(){
actInd.hide();
};
But this does not seem to work. Any help on this would be highly appreciated
1 Answer
-
Accepted Answer
Hey sanchit.. beforeload/onload aren't callbacks that are currently supported in WebView. Instead you'll want to go ahead and
show()
your Activity Indicator as soon as you've added it, and then you can add aload
event listener to the WebView like so:webview.addEventListener("load", function(e) { actInd.hide(); });