开发者

Why won't my HTML page load in Android?

I am using the following code to display an HTML page in a webview:

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");

And the HTML page:

 <!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-bo开发者_StackOverflowx>




 <!-- <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>

But it shows nothing on screen. Please help. I have kept Internet permission also.

I found this logcat message:

06-28 06:33:50.510: INFO/GATE(20523): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>

Thanks.


I think it may be that WebView doesn't, by default, allow javascript to execute. If that's the case then you only need to enable javascript:

webview.getSettings().setJavaScriptEnabled(true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜