G
G
gadzhi152015-05-06 12:08:32
Android
gadzhi15, 2015-05-06 12:08:32

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();
        }
    }
}

How best to implement?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afeozzz, 2015-05-06
@gadzhi15

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();
    }

something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question