title: How to add ProgressDialog while loading content from web view
body: <p>This is my program to load a webpage into a web view. My problem is how to add  ProgressDialog while loading content from web view.</p>
  
  <pre><code>public class Openpage extends Activity {
  WebView wb=null;
  String s1=null;
  
   @SuppressLint({ "SetJavaScriptEnabled", "HandlerLeak" })
  public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.newsfeed);
          Intent i=getIntent();
          s1=i.getStringExtra("link");
          Toast.makeText(this, s1, Toast.LENGTH_LONG).show();
          Log.d(s1, "hai");
          ProgressDialog progress = new ProgressDialog(this);
          progress.setMessage("Loading...");
          new MyTask(progress).execute();
  
  
  
  
      }
   public class MyTask extends AsyncTask&lt;Void, Void, Void&gt; {
        private ProgressDialog progress;
  
      public MyTask(ProgressDialog progress) {
          this.progress = progress;
        }
  
        public void onPreExecute() {
          progress.show();
        }
  
        public Void doInBackground(Void...voids) {
  
  
                  wb=(WebView)findViewById(R.id.webView1);
                  wb.loadUrl(s1);
  
  
  
  
          return null;
  
        }
  
        public void onPostExecute(Void void1) {
          progress.dismiss();
        }
      }
  </code></pre>