18
如何从raw
文件夹加载html
文件在WebView
。我不知道如何在WebView.loadData()
函数中添加这些html
文件的路径。我知道如何从asset
文件夹中加载WebView
文件夹,但在这里遇到问题raw
文件夹。在web视图中从原始文件夹加载html文件
在此先感谢
如何从raw
文件夹加载html
文件在WebView
。我不知道如何在WebView.loadData()
函数中添加这些html
文件的路径。我知道如何从asset
文件夹中加载WebView
文件夹,但在这里遇到问题raw
文件夹。在web视图中从原始文件夹加载html文件
在此先感谢
使用此代码从原始文件夹中加载HTML文件的Web视图:
欲了解更多信息,请参阅the javadoc for WebView:
public class ViewWeb extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView lWebView = (WebView)findViewById(R.id.webView);
lWebView.loadUrl("file:///android_res/raw/your_file_name.html");
}
}
的问题的解决,是WebView.loadUrl( “文件:///android_res/raw/file_name.html”); –
它实际上需要正确的原始文件夹,例如对于不同的语言。这让我感到惊讶,因为这条路看起来非常绝对谢谢。 – plexus
请注意,_aplication id_在_buildVariant_中不同时需要解决方法,例如[带后缀](http://stackoverflow.com/questions/26777566/file-under-res-raw-not-accessible -in-调试buildvariant)。 –