android webview显示空白页 [英] android webview displaying blank page
问题描述
即使在加载HTML代码时也是如此。我得到一个空白的白页,没有错误没有什么。没有在logcat中。
WebView wview =(WebView)findViewById(R.id.webView1);
wview.getSettings()。setJavaScriptEnabled(true);
我已经尝试所有三个尝试加载任何内容到webview:
wview.loadUrl(http://www.google.com);
wview.loadData(< HTML>< BODY>< H3> Test< / H3>< / BODY>< / HTML>,text / html,utf-8 ;
wview.loadDataWithBaseURL(null,< HTML>< BODY>< H3> Test< / H3>< / BODY>< / HTML>,text / html,utf-8 ,空值);
所有这三个都给我相同的结果。没有什么。
任何想法?
可能有点太晚了,但是我想和大家分享一下我的经验,因为我有同样的问题,花了很多时间。
将 WebView
放在 RelativeLayout
/ strong>而不是 FrameLayout
。
我测试过的是: code> WebView 的 onPageFinished()
每次都被调用,但在屏幕上我有空白页。从 chrome:// inspect
WebView
调试器我能够ping我的 WebView
通过按 inspect
按钮,之后 WebView
立即刷新。我的想法 - WebView
在 FrameLayout
和 RelativeLayout
修复问题(即使 invalidate()
和 requestLayout()
调用没有帮助) p>
I have an android application that I am developing using the emulator running on android 2.3.3 with an embedded WebView in a framelayout nested in a linearlayout (vertical). No matter what code I use it never actually does anything. I have Permissions on the android application set to INTERNET. Even when trying to load just the HTML code. I get a blank white page, no errors no nothing. Nothing in logcat as well.
WebView wview = (WebView)findViewById(R.id.webView1);
wview.getSettings().setJavaScriptEnabled(true);
I have tried all three of these to attempt to load anything into the webview:
wview.loadUrl("http://www.google.com");
wview.loadData("<HTML><BODY><H3>Test</H3></BODY></HTML>","text/html","utf-8");
wview.loadDataWithBaseURL(null, "<HTML><BODY><H3>Test</H3></BODY></HTML>","text/html","utf-8",null);
All three give me the same results. Nothing.
Any ideas?
It might be a bit too late, but I wanted to share my experience with you, because I had the same problem and spent a lot of time on it.
Put your WebView
in RelativeLayout
and not in FrameLayout
.
What I have tested: My WebView
's onPageFinished()
was called every time, but on the screen I got blank page. From chrome://inspect
WebView
debugger I was able to "ping" my WebView
by pressing inspect
button, and after that WebView
was refreshing immediately. My thoughts - WebView
isn't rendered correctly in FrameLayout
, and RelativeLayout
fixes the issue (even invalidate()
and requestLayout()
calls didn't help).
这篇关于android webview显示空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!