android中使用WebView加载html字符串及加载本地图片资源
StringBuffer sb=new StringBuffer();
//添加html
sb.append("<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8'>");
sb.append("<meta charset='utf-8' content='1'></head><body style='color: black'><p></p>");
//
//< meta http-equiv="refresh"content="time" url="url" >
//添加文件的内容
sb.append(bean.getContent());
//加载本地文件
// sb.append("<img src='file:///"+AContext.getFileUtil().getDownloadsPath()+"'>");
sb.append("</body></html>");
// webView.loadData(data, mimeType, encoding);
//设置字符编码,避免乱码
neirongWebView.getSettings().setDefaultTextEncodingName("utf-8") ;
neirongWebView.loadDataWithBaseURL(null,sb.toString(),"text/html", "utf-8", null);;
版权声明:本文为u010945409原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。