Hi guys,
here a small, but very useful code if you are programming apps in LUA with Corona SDK.
If you are using a simple native.newWebView and you want to display a status / loading bar during the request, you can use the following code:
-- show activity indicator
native.setActivityIndicator( true )
-- create the native.newWebView object
webView = native.newWebView( display.contentWidth * 0.5, 200 , display.contentWidth * 0.5, 400 )
-- request the URL
webView:request( theURL )
-- add an event listener to the native.newWebView object
webView:addEventListener( "urlRequest", webViewListener )
-- this function will be called during the request
function webViewListener( event )
print "Entering: webViewListener"
if (event.type == "loaded") then
print("URL: "..event.url)
native.setActivityIndicator( false )
else
native.setActivityIndicator( true )
end
end
No comments:
Post a Comment