Answer the question
In order to leave comments, you need to log in
Stopping ProgressDialog in webView. How to do?
Good afternoon.
I decided to start writing the first application on android. I use the webView component for this. I also added a page loading indicator, but I can't complete it correctly.
public class MainActivity extends Activity {
private WebView mWeb;
private class WebViewer extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url)
{
view.loadUrl(url);
return true;
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWeb=(WebView)findViewById(R.id.web);
mWeb.getSettings().setJavaScriptEnabled(true);
mWeb.loadUrl("http://randevu05.ru/");
mWeb.setWebViewClient(new WebViewer());
ProgressDialog.show(MainActivity.this, "", "Загрузка. Пожалуйста подождите...", true);
}
@Override
public void onBackPressed() {
if (mWeb.canGoBack()) {
mWeb.goBack();}
else {
super.onBackPressed();
}
}
}
Answer the question
In order to leave comments, you need to log in
private class WebViewer extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(mWebView, url);
progressDialog.dismiss();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question