当我将此ProgressDialog
添加到我的Webview
应用中时,任何人都可以帮助我工作正常但是当页面加载时progress dialog
没有被解雇,任何人都可以帮助我我使用这个Fragment
public static ProgressDialog progressDialog;
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
swipeRefreshLayout.setRefreshing(true);
progressDialog.show(getActivity(), "Loading...", "Please wait YouTube is Loading...");
super.onPageStarted(view, url, favicon);
}
public void onPageFinished(WebView view, String url) {
swipeRefreshLayout.setRefreshing(false);
getActivity().setTitle(view.getTitle());
if(progressDialog!=null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
super.onPageFinished(view, url);
}
});
现在感谢所有帮助我的人编辑的代码
public static ProgressDialog progressDialog;
//Under onCreate View
progressDialog = ProgressDialog.show(getActivity(), "Loading...", "Please wait YouTube is Loading...");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
swipeRefreshLayout.setRefreshing(true);
super.onPageStarted(view, url, favicon);
}
public void onPageFinished(WebView view, String url) {
swipeRefreshLayout.setRefreshing(false);
getActivity().setTitle(view.getTitle());
if(progressDialog!=null && progressDialog.isShowing()) {
progressDialog.dismiss();
progressDialog.hide();
}
super.onPageFinished(view, url);
}
});
答案 0 :(得分:0)
从onPageStarted()
方法移出以下行,因为它将针对每个基础网址进行调用,除非每个css
和js
文件都已加载,否则它将继续显示
progressDialog.show(getActivity(), "Loading...", "Please wait YouTube is Loading...");
答案 1 :(得分:0)
确保if(progressDialog!=null && progressDialog.isShowing())
此条件返回true。在那里设一个断点并确保它们都是真的。
试
progressDialog.hide()
答案 2 :(得分:0)
请试试这段代码
progressDialog = ProgressDialog.show(getActivity(), "Loading...", "Please wait YouTube is Loading...");
希望有所帮助