gpt4 book ai didi

java - 进度对话框在 android studio 中不起作用

转载 作者:行者123 更新时间:2023-11-29 23:32:07 25 4
gpt4 key购买 nike

我想在我的应用程序中显示进度对话框,直到它加载 URL 并显示它。但它没有显示进度对话框。请帮助我。

  setContentView(R.layout.activity_main);
mywb = (WebView) findViewById(R.id.webView);

ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("The Book Street");
progressDialog.setMessage("Loading");
progressDialog.setProgressStyle(progressDialog.STYLE_SPINNER);

progressDialog.show();

progressDialog.setCancelable(false);

WebSettings webSettings = mywb.getSettings();
webSettings.setJavaScriptEnabled(true);
mywb.loadUrl("http://www.thebookstreet.com");

progressDialog.dismiss();

mywb.setWebViewClient(new WebViewClient());

最佳答案

像这样更改您的 webview 客户端:

mywb.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressDialog.show();
}

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressDialog.dismiss();
}

});

关于java - 进度对话框在 android studio 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52541054/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com