我需要从webview保存页面,然后在webview中打开它。我找到了方法saveWebArchive并编写了代码:
Timestamp tm = new Timestamp(new Date().getTime());
String fileName = String.format("web_file_%d.mht",tm.getTime());
String path = dir.toString() + File.separator + fileName;
view.getWebView().saveWebArchive(path);
然后我加载页面,其中model.getContentPath()是来自上面代码的路径
webView.loadUrl("file:///"+model.getContentPath());
我没有CSS样式等页面... 你能说一下如何从网页上保存和加载看起来像原版的页面吗?