This question has already been answered:
How to track WebView inside WebView to make ProgressBar while another page is WebView
This question has already been answered:
How to track WebView inside WebView to make ProgressBar while another page is WebView
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 .
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
Source: https://ru.stackoverflow.com/questions/736324/
All Articles