title: Hide Progress Bar after Webview loaded
body: <p>I'm new on android studio. My problem is that the progress bar does not stop spinning after the webview finished loading.</p>
  
  <p>I have also tried with this one- </p>
  
  <pre><code>progressbar.setVisibility(View.VISIBLE); //to show
          progressbar.setVisibility(View.GONE); // to hide
  </code></pre>
  
  <p>But the error not resolved</p>
  
  <p>My first Fragment Java Class-</p>
  
  <pre><code>import android.app.AlertDialog;
  import android.app.Fragment;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.ProgressBar;
  
  import com.google.android.gms.ads.AdRequest;
  import com.google.android.gms.ads.AdView;
  
  
  public class firstfragment extends Fragment{
  
      public WebView mywebview2;
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
  
          View v = inflater.inflate(R.layout.first_layout, container, false);
          mywebview2 = (WebView) v.findViewById(R.id.WebView);
          mywebview2.loadUrl("https://m.youtube.com");
          mywebview2.setWebViewClient(new WebViewClient());
  
          // Enable Javascript
          WebSettings webSettings = mywebview2.getSettings();
          webSettings.setJavaScriptEnabled(true);
          AdView mAdView = (AdView) v.findViewById(R.id.adView);
          AdRequest adRequest = new AdRequest.Builder().build();
          mAdView.loadAd(adRequest);
          return v;
      }
  
      public void onPageFinished(WebView view,String url){
          ProgressBar progressbar = (ProgressBar) view.findViewById(R.id.progressBar2);
          progressbar.setVisibility(View.VISIBLE); //to show
          progressbar.setVisibility(View.GONE); // to hide
      }
  
  }
  </code></pre>