是否可以使用真正的 ProgressBar 加载多个网页(包括 html、images、JS、css )到 WebView 缓存?我知道可以通过这种方式加载一页:
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
URL = "https://stackoverflow.com"
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setAppCacheMaxSize(1024 * 1024 * 8);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webView.getSettings().setAppCachePath(appCachePath);
if (isNetworkAvailable()) {
appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
} else {
Log.e(TAG,"Load page from cache");
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ONLY);
}
这将使该页面的离线加载成为可能,但是是否可以通过任何方式创建自定义 WebView,我将有机会在数组或列表中加载多个 URL,例如
List<String> urls = new ArrayList<>();
urls.add("https://stackoverflow.com");
urls.add("https://google.com");
urls.add("https://facebook.com");
webView.loadURL(ursl);
而且我还需要一个完整的进度条来加载这些网页。我知道我可以像这样为 webView 设置 WebChromeClient:
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
Log.d(TAG,"onProgressChanged" + progress);
}
}
但当我需要几页的总进度时,它只会显示加载一个网页的进度。
我不想自己写一个WebPage grabber,把它放在内部Storage中,因为这会花很多时间,而且可能会导致很多不同的bug和错误。
拜托,你能给我一些想法吗?
最佳答案
is it possible to load multiple WebPages(including html,images,JS,css ) to WebView cache with real ProgressBar ?
不可能。
访问 Android 文档以获取 reference .
关于android - WebView 多个预缓存与 progressBar Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43407070/