title: Getting void android.webkit.WebView.loadUrl while loading webview in dialog in Android?
body: <p>I am getting this error Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.loadUrl when I try to load a webview inside a dialog in android.I have attached the log and code and I have used below. Kindly provide your knowledge to solve it.</p>
  
  <blockquote>
    <p>02-06 18:07:41.605: E/AndroidRuntime(1492): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tanas.activities/com.tanas.activities.ContactInfoActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.loadUrl(java.lang.String)' on a null object reference
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.ActivityThread.access$800(ActivityThread.java:144)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.os.Handler.dispatchMessage(Handler.java:102)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.os.Looper.loop(Looper.java:135)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.ActivityThread.main(ActivityThread.java:5221)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at java.lang.reflect.Method.invoke(Native Method)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at java.lang.reflect.Method.invoke(Method.java:372)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    02-06 18:07:41.605: E/AndroidRuntime(1492): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.loadUrl(java.lang.String)' on a null object reference
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at com.tanas.activities.ContactInfoActivity.showCustomDialog(ContactInfoActivity.java:37)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at com.tanas.activities.ContactInfoActivity.onCreate(ContactInfoActivity.java:21)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.Activity.performCreate(Activity.java:5933)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
    02-06 18:07:41.605: E/AndroidRuntime(1492):     ... 10 more</p>
  </blockquote>
  
  <p>Code is </p>
  
  <pre><code>m_dialog = new Dialog(ContactInfoActivity.this, R.style.Dialog_No_Border);
      m_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  
  
      LayoutInflater m_inflater = LayoutInflater.from(ContactInfoActivity.this);
      View m_view = m_inflater.inflate(R.layout.activity_contact, null);
      m_llMain = (LinearLayout) m_view.findViewById(R.id.cadllMain);
  
      m_llMain.setBackgroundResource(R.drawable.btn_style_roundcorner);
  
      WebView wv = (WebView) m_dialog.findViewById(R.id.webview1);
      //WebView wv = new WebView(this);
      wv.loadUrl("http:\\www.google.com");
      wv.setWebViewClient(new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              view.loadUrl(url);
  
              return true;
          }
      });
  
      m_dialog.setContentView(m_view);
      m_dialog.show();
  </code></pre>