surendra
surendra

Reputation: 2267

Progressdialog for phonegap projects

I am very new to html5, css and javascript. i have knowledge in android development. Now i have started working on phonegap projects.

In my project i want show a loader just like a progressdialog in android when application moves from one screen to another screen or loading something.

Can any one help me to do this in html5?

Upvotes: 0

Views: 1899

Answers (2)

Santosh
Santosh

Reputation: 53

I had similar need . I was able to do it using navigator object. Please find below sample code to load data in background

function someJSFunctionLoadingData() {
   navigator.notification.activityStart("Your message....", "loading");
   ////// some activity
   navigator.notification.activityStop();

}

Further to navigate around you could use introduce a small delay ( 2 secs) and let progress bar load during that time and then direct user to the url you need. Below is the example for same

function loadMyUrl(){
    navigator.notification.activityStart("Loading some url....", "loading");
    setTimeout(function loadMyUrl(){
                      navigator.app.loadUrl('file:///android_asse/www/someurl.html');
                      navigator.notification.activityStop();
                      }, 2000 ); 
 }

I got above idea from this link

Upvotes: 3

MikeIsrael
MikeIsrael

Reputation: 2889

An easy solution would be to just create a css based spinner element and set it to hidden/visible when needed via your js.

I searched and found tons of examples online here is one for example.

Upvotes: 0

Related Questions