title: How to display a webview inside a custom dialog in android?
body: <p>I am trying to display a webview inside a custom dialog,its working outside the dialog.Here is my code below along with xml of the custom dialog xml.Kindly give me your expertise on this ,thanks.</p>
  
  <pre><code>public class TellaFriend extends Activity {
  
  static final int CUSTOM_DIALOG_ID = 0;
  TextView customDialog_TextView;
  EditText customDialog_EditText;
  Button customDialog_Update, customDialog_Dismiss;;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      Button buttonStartDialog = (Button) findViewById(R.id.button1);
      buttonStartDialog.setOnClickListener(new Button.OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              showDialog(CUSTOM_DIALOG_ID);
          }
      });
  }
  
  private Button.OnClickListener customDialog_UpdateOnClickListener = new Button.OnClickListener() {
      @Override
      public void onClick(View arg0) {
          // TODO Auto-generated method stub
          String sharedFact = customDialog_EditText.getText().toString();
      }
  };
  
  private Button.OnClickListener customDialog_DismissOnClickListener = new Button.OnClickListener() {
      @Override
      public void onClick(View arg0) {
          // TODO Auto-generated method stub
          dismissDialog(CUSTOM_DIALOG_ID);
      }
  };
  
  @Override
  protected Dialog onCreateDialog(int id) {
      // TODO Auto-generated method stub
      Dialog dialog = null;
      switch (id) {
      case CUSTOM_DIALOG_ID:
  
          dialog = new Dialog(this);
          dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
          dialog.setCancelable(false);
          dialog.setContentView(R.layout.customlayout);
  
          WebView webView = (WebView) findViewById(R.id.webview);
          webView.getSettings().setJavaScriptEnabled(true);
          webView.setBackgroundColor(Color.BLACK);
          webView.loadUrl("file:///android_asset/Help.html");
  
          webView.setWebViewClient(new GameClient());
  
          customDialog_Update = (Button) dialog.findViewById(R.id.submit);
          customDialog_Dismiss = (Button) dialog.findViewById(R.id.buttonone);
  
          customDialog_Update.setOnClickListener(customDialog_UpdateOnClickListener);     customDialog_Dismiss.setOnClickListener(customDialog_DismissOnClickListener);
          break;
      }
      return dialog;
  }
  
  public class GameClient extends WebViewClient {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          view.loadUrl(url);
          return true;
      }
  }
  }
  </code></pre>
  
  <p>and xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="290dp" android:background="#ffffff" 
  android:layout_height="350dp" &gt;
  
  &lt;RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_margin="15dp"
      android:orientation="vertical"
      android:padding="2dp" &gt;
  
      &lt;ScrollView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scrollbarSize="12dip"
      android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
      android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track" &gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" &gt;
  
          &lt;LinearLayout
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical" &gt;
  
              &lt;WebView android:id="@+id/webview" android:layout_width="fill_parent"  
      android:layout_height="fill_parent" /&gt;
  
          &lt;/LinearLayout&gt;        
  
              &lt;Button
                  android:id="@+id/backbtn" android:layout_marginTop="20dp"
                  android:layout_width="165dp"
                  android:layout_height="57dp"
                  android:layout_gravity="center_horizontal"           
                  android:text="Call and Talk with a buyer now"
                  android:textColor="#000000"
                  android:textSize="13sp"
                  android:textStyle="bold" /&gt;
  
              &lt;Button
                  android:id="@+id/submit" android:layout_marginTop="20dp"
                  android:layout_width="165dp"
                  android:layout_height="57dp"
                  android:layout_gravity="center_horizontal"                 
                  android:text="Email Buyer now to confirm selling details"
                  android:textColor="#000000"
                  android:textSize="13sp"
                  android:textStyle="bold" /&gt;       
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;     
  &lt;/RelativeLayout&gt;
  &lt;RelativeLayout 
  android:layout_width="290dp" android:background="@drawable/abg" 
  android:layout_height="350dp" android:layout_margin="1dp"&gt;
  &lt;Button
      android:id="@+id/buttonone" 
      android:layout_width="25dp"
      android:layout_height="25dp"
      android:layout_alignParentRight="true"
      android:layout_margin="5dp"
      android:background="@drawable/round_button_background"
      android:gravity="center_vertical|center_horizontal"
      android:onClick="cancelActivity"
      android:text="X" 
      android:textColor="#ffffff"
      android:textSize="13sp"
      android:textStyle="bold" /&gt;
  
  &lt;/RelativeLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Error log is </p>
  
  <pre><code>05-02 10:00:04.922: E/AndroidRuntime(488): FATAL EXCEPTION: main
  05-02 10:00:04.922: E/AndroidRuntime(488): java.lang.NullPointerException
  05-02 10:00:04.922: E/AndroidRuntime(488):  at com.kk.TellaFriend.TellaFriend.onCreateDialog(TellaFriend.java:91)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.onCreateDialog(Activity.java:2472)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.createDialog(Activity.java:881)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.showDialog(Activity.java:2547)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.showDialog(Activity.java:2514)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at com.kk.TellaFriend.TellaFriend$3.onClick(TellaFriend.java:45)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.view.View.performClick(View.java:2408)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.view.View$PerformClick.run(View.java:8816)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.os.Handler.handleCallback(Handler.java:587)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.os.Handler.dispatchMessage(Handler.java:92)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.os.Looper.loop(Looper.java:123)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at java.lang.reflect.Method.invokeNative(Native Method)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at java.lang.reflect.Method.invoke(Method.java:521)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  05-02 10:00:04.922: E/AndroidRuntime(488):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>