【问题标题】:Loading local html file from asset folder into a webview将本地 html 文件从资产文件夹加载到 webview
【发布时间】:2012-09-05 04:25:26
【问题描述】:

将本地 html 文件从资产加载到 web 视图时出现问题。 HTML 页面有 javascript 代码,所以我使用了 webview.setJavaScriptEnabled(true) 来启用它。它加载了 html 页面,但不是所有的小部件都正确加载。任何建议...

【问题讨论】:

  • 请分享代码,以便我们查看您是否遗漏了什么。
  • 你需要填写 3 个重要的东西,即 HTML 数据/文件,Mimetype & encoding 以使 webview 正确理解它。

标签: android webview


【解决方案1】:
public class ViewWeb extends Activity {  

        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);
            setContentView(R.layout.webview);  
            WebView wv;  
            wv = (WebView) findViewById(R.id.webView1);  
            wv.loadUrl("file:///android_asset/hello.html");   
        }  
    }

【讨论】:

  • 我做的完全一样,甚至为 webview 启用了 Javascript。但是,我有一个文件夹,其中有一个 HTML 页面和许多链接到它的 javascript 文件。它会显示 HTML 页面,但无法正确呈现图像。
猜你喜欢
  • 2017-11-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多