WebView 在某些手机上不显示加载的 Html
我的一个 Activities
中有一个 WebView
,我想在其中加载 Html
页面。该页面包含 jquery-mobile
和一些 html
。因此,我在我的 Activity
中执行以下操作:
mWebView=(WebView) findViewById(R.id.MyWebView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient(){
[...]
});
mWebView.loadUrl("http://www.mymobilepage.html");
问题是页面已加载并显示在模拟器和 HTC Desire 上,但当我尝试将其加载到 LG Optimus One 上时,什么也没有得到显示。事件 onPageStarted
和 onPageFinished
都在我的 WebViewClient
中触发,但只显示一个空白页面,而且我没有任何错误我的 LogCat。
提前致谢。
I have a WebView
in one of my Activities
where I want to load a Html
page. The page contains jquery-mobile
and some html
. So I do the following in my Activity
:
mWebView=(WebView) findViewById(R.id.MyWebView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient(){
[...]
});
mWebView.loadUrl("http://www.mymobilepage.html");
The problem is that the page gets loaded and displayed on the emulator, and on a HTC Desire, but when I try to load it on a LG Optimus One nothing gets displayed. The events onPageStarted
and onPageFinished
both get fired in my WebViewClient
but just a blank page is displayed, and also I don't have any errors in my LogCat
.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
调用 onPageFinished 时,页面可能未完全渲染。 文档指出:
但是,请注意 onNewPicture 已被记录为已弃用和过时。我在此处询问替换/替代方案。
When onPageFinished is called, the page may not be completely rendered. The documentation states:
However, note that onNewPicture is documented as deprecated and obsolete. I ask about a replacement/alternative here.
这应该是一条评论,但由于上面有一些代码,我添加了作为响应。
尝试将默认背景更改为透明,并在页面加载后立即发出警报,以确保至少 html 被解释:
并且在加载网页时:
并让我们知道是否发生了某些情况。
This should be a comment, but since there is a bit of code on it I've added as response.
Try changing default background to transparent and alerting as soon as the page is loaded, just to be sure that at least the html is being interpreted:
and when loading the webpage:
and let us know if something happened.
试试这个:
Try this:
您是否在模拟器上检查了不同版本的 html/js 代码?较新的 Android 版本具有较新版本的 WebKit,这可能是问题所在。
我还会检查您是否将 LogCat 设置为仅显示错误消息,或调试+信息+警告+错误消息。根据 this,javascript 错误应显示为调试消息。
Have you checked your html/js code with different versions on the emulator? Newer Android versions have newer versions of WebKit, that might be the problem.
I would also check if you have LogCat set to show Error messages only, or Debug+Info+Warning+Error messages. According to this, the javascript errors should show up as Debug messages.
我遇到了与此类似的问题,我发现调用clearview然后重新加载似乎可以清除它 - 如:
I had a similar issue to this, I found that calling clearview and then reload seemed to clear it up -- as in: