java - android中webview无网络时怎么实现点击加载?
巴扎黑
巴扎黑 2017-04-18 10:33:27
0
5
411

具体看图:

webview无网络时出现点击加载页面,

巴扎黑
巴扎黑

reply all(5)
小葫芦

It can be downloaded even when there is no network. Where can I download it?

左手右手慢动作

When there is no network, it is recommended to load the non-network html and other resource files under the assets folder to give users a no-network prompt.

Sample code:

wv.loadUrl("file:///android_asset/no_network.html");
Peter_Zhu

This involves js and Android interaction, please see my other answer:

https://segmentfault.com/q/1010000007840711?_ea=1500127

Click the button and refresh the webview in js

Peter_Zhu

In fact, it’s simpler. You can implement this interface directly without network (without using webview, just use an imageview, textview, and button to lay out the layout). When the webpage can be loaded, the webview will be displayed

伊谢尔伦

As @sens said, not only the webview will have loading errors, but other pages will have loading errors, so it is recommended to adopt @sens's solution and write a refreshData(...) method in BaseActivity. Just click to refresh this page.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template