android - 为 webview 预加载数据

标签 android android-widget

我有一个 Activity ,点击一个小部件,启动另一个带有 WebView 的 Activity 。此 WebView 加载速度相当慢。

我想做的是预加载 WebView 的内容,以便即时显示。

我尝试了建议的解决方案 here , 这会起作用.. 但事实上第一个屏幕最好在纵向中查看,而 WebView 最好横向查看。因此,如果屏幕方向发生变化(通过用户操作或 setRequestedOrientation()),Activity 将重新加载并显示第一个屏幕(根本不是我想要的)。

有什么想法吗?

最佳答案

And as such, if the screen orientation changes (either by user action or setRequestedOrientation()), the Activity reloads and the first screen is displayed (not what I want at all).

然后改变那个行为。 WebView 是使用 android:configChanges="keyboardHidden|orientation" 管理方向配置更改的合理借口。缺点是您必须自己处理所有资源更改。从好的方面来说,您预加载的 WebView 保持不变。

关于android - 为 webview 预加载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4938241/

相关文章:

java - 在 API 9 以下使用 Arrays.copyOfRange()

android - Cordova config.xml 首选项 android-installLocation

android - 我应该为我的 Android 应用程序使用什么事件监听器

android - 如何将android应用程序与droid mobile相匹配?

android - 在android中设置应用程序名称的问题?

android - 泄露的 IntentReceiver android.widget.ZoomButtonsController?

android - 如何在android中缓存图像?

android - 如何滚动到 android TextView 的末尾?

android - 将一个 imageView 放在另一个 ImageView 上 : Android

android - 动态创建 Buttons 并设置 onClickListener