This question has already been answered:

How to track WebView inside WebView to make ProgressBar while another page is WebView

Reported as a duplicate by the participants αλεχολυτ , eugeneek , Sasha Omelchenko , br3t , Mark Shevchenko October 27, '17 at 12:44 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • excuse me, but where is the click inside the webview to the page loading status? maybe you want to respond to the beginning of the page load? - mirypoko
  • @mirypoko When the starting page loads, everything is fine, but by clicking on the link it takes a long time to load and it seems that the phone is frozen, I would like to make a progress bar to make it clear that everything works and loads - Dima Kalistratov
  • try using the onPageStarted event to launch the progress bar - mirypoko
  • Example: stackoverflow.com/a/8467430 - woesss

1 answer 1

In the onCreate () method, where you initialize your WebView :

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.web_view); web_view = (WebView) findViewById(R.id.web_view); web_view.setWebViewClient(new MyWebViewClient()); web_view.loadUrl("https://example.com/abc"); progressDialog = new ProgressDialog(this); progressDialog.setMessage("Загрузка..."); progressDialog.show(); } 

WebViewClient:

 private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); if (!progressDialog.isShowing()) { progressDialog.show(); } return true; } @Override public void onPageFinished(WebView view, String url) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } } 

The answer is taken from SO.com