我正在尝试将html文件加载到webview中,但webview仍然是空白的。有人可以帮助我实现这个目标吗?
这是我的HTML
<script src="http://france.meteofrance.com/portlet/plugins/meteo/VignetteMeteoVille3.javascript?idLieu=431200" charset="UTF-8"></script>
这是在创建方法
// oncreate方法
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.rss_feed);
webcontent = (WebView)findViewById(R.id.webViewHistoire);
webcontent.setWebViewClient(new NewsClient());
webcontent.getSettings().setJavaScriptEnabled(true);
webcontent.getSettings().setPluginsEnabled (true);
webcontent.getSettings().setDomStorageEnabled(true);
webcontent.loadUrl("file:///android_asset/home.html");
}
//返回键
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webcontent.canGoBack()) {
webcontent.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private class NewsClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
}
答案 0 :(得分:1)
你的html文件代码是用<html>
标签写的吗?如果没有,那么请写如下:
<html> <head> <script language="JavaScript" src="http://france.meteofrance.com/portlet/plugins/meteo/VignetteMeteoVille3.javascript?idLieu=431200" charset="UTF-8"> </script> </head> </html>
并尝试在webview中加载它。