安卓preLOAD一个网址的WebView同时启动画面是显示 [英] Android preload a url into WebView while splashscreen is showing

查看:150
本文介绍了安卓preLOAD一个网址的WebView同时启动画面是显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启动画面这几秒钟后打开了,有一个web视图的主要活动的应用程序。问题在于,只有那时,确实主要活动开始加载的网址,这有时需要几秒钟。看来愚蠢的双待。但是,我尝试pre-负荷的WebView已经不太那么成功。

I have an app with a splash-screen which after a few seconds opens up the main activity that has a WebView. The problem is that, only then, does the main activity start to load the URL, which sometimes take several seconds. It seems silly for the double wait. However, my attempts to pre-load the WebView have been less then successful.

这个问题的实质是,闪屏和主要活动是两个不同的活动和web视图是资源约束(布局)的主要活动。复制的WebView(webview2 = webview1)不工作,这并不奇怪。

The essence of the issue is that the splash screen and main activity are two different activities and the WebView is resource bound (layout) to the main activity. Copying the WebView (webview2=webview1) doesn't work, not surprisingly.

建议?

推荐答案

请按照下列步骤。

你的屏幕上1)设置启动布局。

1) set splash layout on your screen.

2)启动一个新线程,在这个线程夸大包含web视图的布局。

2) start a new thread, in this thread inflate a layout that contains webview.

3)负载URL的web视图。设置的WebView客户端的WebView要知道,当你的页面加载完成。 有一个简单的例子。覆盖onPageFinished。

3) Load url in webView. Set webview Client to webview to know when your page loading completes. There is a quick example. override onPageFinished.

4)现在打破了线,并通过这种膨胀视图下一个活动,并将其设置为的setContentView(inflatedView);

4) Now break the thread and pass this inflated view to next activity, and set it to setContentView(inflatedView);

感谢。

这篇关于安卓preLOAD一个网址的WebView同时启动画面是显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆