Progress bar not shown Phonegap/Android
I am using Phonegap with my Android project and i am not able to see the Progress Bar here is my code.
My Main class inherites the DroidGap class
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
Window.PROGRESS_VISIBILITY_ON);
final Activity MyActivity = this;
this.appView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Make the bar disappear after URL is loaded, and changes
// string to Loading...
MyActivity.setTitle(" Please wait");
MyActivity.setProgress(progress * 100); // Make the bar
// disappear after URL
// is loaded
// Return the app name after finish loading
if (progress == 100)
MyActivity.setTitle(R.string.app_name);
}
});
this.appView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// Handle the error
}
开发者_如何学JAVA @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
Nothing happens any idea if i try the same for a simple WebView it works properly...
I had the same problem, using Phonegap 1.0 and overriding the DroidGap::init
method to include code like the OP posted. I could tell that onProgressChanged
was called because messages printed to the log did show up, but the progress bar did not show. Eventually I found a solution.
In the onCreate
method of DroidGap
, the window title is switched off:
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
This needs to be commented out for the progress bar to show.
My suggestion is to copy the whole DroidGap.java
file to a new class (let's say DroidGapModified
), add the progress bar changes and extend this new class from your main app.
精彩评论