【发布时间】:2013-01-10 23:31:06
【问题描述】:
我正在使用 WebView 来显示一个 html 页面,该页面存储在 \raw\ 目录中,因此我可以轻松地对其进行本地化。 我使用
加载页面 InputStream inputStream = getResources().openRawResource(R.id.htmlPage1);
StringWriter writer = new StringWriter();
try {
IOUtils.copy(inputStream, writer);
} catch (IOException e) {
e.printStackTrace();
}
String x = writer.toString();
WebView w = (WebView) myFragmentView.findViewById(R.id.webView);
w.loadDataWithBaseURL("file:///android_asset/", x, "text/html", "utf-8", null);
效果很好。 html页面使用的图片和css文件存放在\assets\目录下。
现在我想在我的 html 页面中添加指向另一个本地页面(单击此处)的链接。 WebView 尝试从资产加载页面(这似乎是正确的行为)。不幸的是,\assets\ 文件夹没有本地化。
如何在不放弃本地化功能的情况下链接到其他本地html页面?
谢谢!
【问题讨论】: