【发布时间】:2012-02-02 23:33:17
【问题描述】:
我在将我的项目资产文件夹中的 html 文件加载到 web 视图中时遇到了困难。我查看了许多教程和解决方案,但似乎没有一个适合我。
在我项目的资产文件夹中,我有两个简单的 html 文件。 index.html 和 faq.html (计划是在我的帮助文档中使用这种结构)
我的代码:
WebView wv = (WebView)findViewById(R.id.webview1);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
wv.loadUrl("file:///android_asset/index.html");
webview 显示以下内容:
Web Page Not Available
The Web Page at file:///android_asset/index.html could not be loaded as:
The requested file was not found. index.html
从我所阅读的所有内容来看,我在这里应该可以工作,但事实并非如此。
【问题讨论】: