user1419810 user1419810 - 1 year ago 107
Android Question

Spinner wont dissapear on webview load - android

I'm trying to set a progress spinner (in andorid) to disappear once the webview has loaded but cant get it to work at all, the spinner appears using onPageStarted but doesn't disappear using onPageFinished does anyone know what I'm doing wrong?

public class MainActivity extends AppCompatActivity {

private WebView mWebView;

private ProgressBar spinner;

protected void onCreate(Bundle savedInstanceState) {

mWebView = (WebView) findViewById(;

spinner = (ProgressBar)findViewById(;


// Enable Setup Webview
// WebView myWebView = (WebView) findViewById(;
// myWebView.setWebViewClient(new MyWebViewClient());

mWebView.setWebViewClient(new WebViewClient() {
public void onPageStarted(WebView view, String url) {
public void onPageFinished(WebView view, String url) {
// do your stuff here

// Enable Javascript
WebSettings webSettings = mWebView.getSettings();

// Force links and redirects to open in the WebView instead of in a browser
mWebView.setWebViewClient(new WebViewClient());

Answer Source

you are overwriting old webViewClient.

// Remove this because you already set one above which is responsible for showing and hiding progressbar.

mWebView.setWebViewClient(new WebViewClient());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download