有没有办法通知用户等待WebView加载图像
我的活动中有 WebView,我需要在该 webview 中加载一些本地字符串( html )。问题是本地 html 包含来自远程服务器的图像,因此需要时间下载和显示。有没有办法通知用户等待,比如旋转对话框之类的?如何通知用户等待内容?
I have WebView in my activity and I need to load some local string ( html ) in that webview. Problem is that local html contains images from remoted servers so it needs time to download and show. Is there way to notify user to wait, like spinning dialog or something ? How to notify user to wait content ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
没有内置功能可以满足您的需要。
但是,您可以设置
WebViewClient
WebView
(请参阅webView.setWebViewClient()
) 并重写方法onPageStarted()
和onPageFinished ()
。通过这种方式,您可以显示ProgressDialog
或其他进度指示器(使用RotateAnimation
例如)当页面已开始加载,并在页面完成加载后将其关闭。There is not built-in function for doing what you need.
However, you can set a
WebViewClient
onWebView
(seewebView.setWebViewClient()
) and override the methodsonPageStarted()
andonPageFinished()
. In this way you can show aProgressDialog
or other progress indicator (use aRotateAnimation
for example) when the page has started loading and dismiss it later when the page has finished loading.您可以使用 css 在 html 页面中执行此操作或 javascript。
You could do that in your html page using css or javascript.
您可以为 webview 设置 webviewCLient ,您将在 PageFinished 上收到回调。
You could set a webviewCLient to the webview and you will get callback onPageFinished.
ts 在所有设备上正常工作使用此链接:- 加载 Web 视图进度对话框
ts working fine on all devices Use this link :- Load Web View ProgressDialog