我使用以下代码在webview中显示HTML页面:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.socialmedia
);
webview = (WebView) findViewById(R.id.webview);
webview.loadUrl("file:///android_asset/www/facebook.html");
HTML页面:
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
</head>
<body>
<div id="container"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1" ></script>
<fb:like-box href="http://www.facebook.com/workatcareerbuilder" width="292" show_faces="true" stream="true" header="true" hScrollbar:true></fb:like-box>
<!-- <script>
function twitter(){
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 6,
interval: 6000,
title: '@palafo',
width: 250,
height: 300,
theme: {
shell: {
background: '#ad0000',
color: '#ffffff'
},
tweets: {
background: '#ffffff',
color: '#444444',
links: '#ad0000'
}
},
features: {
scrollbar: true,
loop: false,
live: true,
hashtags: true,
timestamp: true,
avatars: true,
behavior: 'all'
}
}).render().setUser('imomentous').start();
}
</script> -->
</body>
</html>
但它在屏幕上没有显示任何内容。请帮忙。我也保留了互联网许可。
我发现了这个logcat消息:
06-28 06:33:50.510: INFO/GATE(20523): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
感谢。
答案 0 :(得分:2)
我认为WebView可能默认情况下不允许执行javascript。如果是这种情况,那么您只需要启用javascript:
webview.getSettings().setJavaScriptEnabled(true);