android - Progress bar while URL loading in WebView -


I have the code below to show a progress bar loading in the form of URL load in WebWeb. Although the line of code:

  webView.setWebViewClient (new MyWebViewClient ()); There is an error in  

:

  Constructor MyWebViewClient () is undefined  

What else is needed for this work?

WebViewActivity:

  increases the public class WebViewActivity activity {Private WebView webView; Crate on Public Zero (Bundle Saved Instantstate) {Super. Secret (Saved Instantstate); SetContentView (R.layout.webview); Progress PB = new progress bar (WebViewActivity.This); Webview = (webview) Find VVBIID (Raid WebViv 1); WebView.getSettings () setJavaScriptEnabled (true). WebView.setWebViewClient (new MyWebViewClient (pb)); WebView.loadUrl ("http://www.google.com"); } @Override Public Boolean OnKeyDown (Integer Keycode, KeyEvent Event) {if (event.getAction () == KeyEvent.ACTION_DOWN} {Switch (Keycode) {Case KeyEvent.KEYCODE_BACK: if (webView.canGoBack ()) {webView.goBack (); } Else {finish (); } Back true; }} Return super.Condondon (keycode, event); }}  

MyWebViewActivity:

class provides MyWebViewClient WebViewClient {Personal ProgressBar progressBar; Public MyWebViewClient (Progressbar PB) {this.progressbar = pb; Pb.setVisibility (see .VISIBLE);} @ Override Public Boolean ShouldoverRural URL (webview view, string url) {view.loadUrl (url); Return super.shouldOverrideUrl loading (see, url); } @PageFinished (WebView View, String URL) overwrite @ override public {// TODO auto-generated method stub super.pagefinished (see, url); ProgressBar.setVisibility (View.GONE); }}

Crash log:

  10-17 20: 18: 35.774: E / Android randomime (10492): fatal exception: main 10-17 20: 18: 35.774: E / AndroidRuntime (10,492): java.lang.RuntimeException: java.lang.NullPointerException 10-17 20 :: 18: 35.774: Initiating Activity ComponentInfo {app.myapp / app.myapp.WebViewActivity} Disable E / AndroidRuntime (10,492): android.app.ActivityThread.performLaunchActivity (ActivityThread.javaaxy205) 10-17 20:18: 35.774: E / AndroidRuntime (10,492): android.app.ActivityThread.handleLaunchActivity (ActivityThread.java On: 2240) 10-17 20: 18: 35.774: E / AndroidRuntime (10,492): android.app.ActivityThread.access $ 600 (ActivityThread.java:139) 10-17 20: 18: 35.774: E / AndroidRuntime ( 10,492): android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1262) at 10-17 20: 18: 35.77 4: E / AndroidRuntime (10,492): android.os.Handler.dispatchMessage (Handler.java:99) in 10- 17 20:18: 35.774: E / Android Random (10492): Android.OS Lopper. Lope (Luor.Java 156) 10-17 20:18:35. 774: E / AndroidRuntime (10,492): android.app.ActivityThread.main (ActivityThread.java:4987) at 10-17 20:18: 35.774: E / AndroidRuntime (10,492): java.lang.reflect.Method.invokeNative (Basic Method) 10-17 20: 18: 35.774: E / Android Random (10492): at java.lang.reflect.Method.invoke (Method. Java 1111) 10-17 20: 18: 35.774: E / Androordantman ( 10,492): com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:784) at 10-17 20: 18: 35.774: E / AndroidRuntime (10,492): com.android.internal.os.zygoteInit . Man (Zeigoteinit. Java T 5151) 10-17 20: 18: 35.774: E / Androindertime (10492): Dlvic. System NetStart.main (native method) 10-17 20: 18: 35.774: E / Android time (10,492): java.lang.NullPointerException 10-17 20: Because of 18: 35.774: E / AndroidRuntime (10,492): app.myapp & Lt; on MyWebViewClient Init & gt; (MyWebViewClient.java:18) 10-17 20 .: 18: 35.774: E / Android Rentem (10492): App. On Map WebviewActivia Connet (WebVActivia.Java 23) 10-17 20: 18: 35.774: E / Android Time (10492): A android.app.Activity.performCreate (Activity.java:4538) 10-17 20: 18: 35.774: E / AndroidRuntime (10,492): android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1071) at 10-17 20:18: 35.774: E / AndroidRuntime (10,492): android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2161) On 10-17 20: 18: 35.774: E / AndroidRuntime (10,492): ... 11 more  

Constructor MyWebViewClient () is undefined This error occurs when the manufacturer is not available in the class as I am B be that you only have a constructor public MyWebViewClient (progress Brd progress bar) . In MyWebViewClient class

you can create the MyWebViewClient class without having to type ProgressBar without the constructor for example.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -