问题加载HTML资产投入的WebView [英] Problems loading html asset into webview

查看:169
本文介绍了问题加载HTML资产投入的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有困难的,从我的项目资产加载HTML文件夹到一个web视图。我已经看过几十个教程和解决方案,但没有似乎为我工作。

I am having difficulty in loading a html file from my project assets folder into a webview. I have looked at dozens of tutorials and solutions but none seem to work for me.

在我的项目的资产文件夹我有两个简单的HTML文件。 index.html,然后的faq.html (该计划是利用这个结构对我的帮助文档)

In my project's assets folder I have two simple html files. index.html and faq.html (The plan is to utilise this structure for my help documentation)

我的code:

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

web视图显示以下内容:

The webview displays the following:

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

这一切我都读什么我这里应该工作,但事实并非如此。

From everything I have read what I have here should work, but it does not.

推荐答案

你的用法是正确的,所以如果有这个问题,你需要检查 index.html的文件存在或不小心,你也可清理项目,然后重建。

your usage is right, so if has this problem, you need check the index.html file existed or not carefully, also you can clean the project, and rebuild it.

这篇关于问题加载HTML资产投入的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆