Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在webview中(进度==100)之后不关闭进度对话框_Android_Webview_Progressdialog - Fatal编程技术网

Android 在webview中(进度==100)之后不关闭进度对话框

Android 在webview中(进度==100)之后不关闭进度对话框,android,webview,progressdialog,Android,Webview,Progressdialog,页面加载后progressdialog未关闭,这里是我缺少的内容 final ProgressDialog progressDialog = new ProgressDialog(Webview.this ); WebView webview= (WebView) findViewById(R.id.webViewID); webview.setWebViewClient(new WebViewClient()); //webview.loadData(content, "t

页面加载后progressdialog未关闭,这里是我缺少的内容

 final ProgressDialog progressDialog = new ProgressDialog(Webview.this );
WebView webview= (WebView) findViewById(R.id.webViewID);
    webview.setWebViewClient(new WebViewClient());

    //webview.loadData(content, "text/html", "UTF-8");
    webview.loadUrl("http://hop.betfanplus.com/10000/0/mega4");

    webview.setWebChromeClient(new WebChromeClient() {
          @Override
          public void onProgressChanged(WebView view, int progress) {
             // progressDialog.show();
             ProgressDialog
                      .show(Webview.this,
                              "ProgressDialog Title",
                                  "ProgressDialog Body");

              if (progress == 100) {
                 progressDialog.dismiss();               
                 }
          }
      });

非常感谢您的帮助。

您仍应使用onPageStarted和onPageFinished

根据我的经验,即使网页无法加载,使用进度百分比也会达到100,所以这是行不通的

boolean loadingFinished = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    final ProgressDialog progressDialog = new ProgressDialog(Webview.this );
    progressDialog.setMessage("ProgressDialog Body");
    progressDialog.show();
    WebView webview= (WebView) findViewById(R.id.webViewID);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setDomStorageEnabled(true);

    webview.setWebViewClient(new WebViewClient() {

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(getApplicationContext(), description, Toast.LENGTH_SHORT).show();
        }

        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            loadingFinished = false;
        }

        public void onPageFinished(WebView view, String url) {

            loadingFinished = true;
            progressDialog.cancel();
        }

    });
    webview.setWebChromeClient(new WebChromeClient());
    webview.loadUrl("http://hop.betfanplus.com/10000/0/mega4");


}

您仍应使用onPageStarted和onPageFinished

根据我的经验,即使网页无法加载,使用进度百分比也会达到100,所以这是行不通的

boolean loadingFinished = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    final ProgressDialog progressDialog = new ProgressDialog(Webview.this );
    progressDialog.setMessage("ProgressDialog Body");
    progressDialog.show();
    WebView webview= (WebView) findViewById(R.id.webViewID);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setDomStorageEnabled(true);

    webview.setWebViewClient(new WebViewClient() {

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(getApplicationContext(), description, Toast.LENGTH_SHORT).show();
        }

        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            loadingFinished = false;
        }

        public void onPageFinished(WebView view, String url) {

            loadingFinished = true;
            progressDialog.cancel();
        }

    });
    webview.setWebChromeClient(new WebChromeClient());
    webview.loadUrl("http://hop.betfanplus.com/10000/0/mega4");


}

您在onProgresschange中使用类本身而不是对象您在onProgresschange中使用类本身而不是对象请根据我的代码告诉我解决方案如果可能,我不希望使用onPageStarted和onPageFinished@html ToSinga我们在聊天中讨论更多问题@Html TosinSure,你可以给我发送一个链接我不知道如何发送请你给我发送chat@Html Tosinpls的链接告诉我根据我的代码的解决方案如果可能,我不想使用onPageStarted和onPageFinished@Html TosInga我们在聊天中讨论更多问题@Html托辛,你可以给我发一个我不知道如何发送的链接,请你给我发chat@Html托辛的链接