一个关于webview加载本地html,执行js给页面传值为空
如题,
List<CtArticle> projectbeanlist = new ArrayList<CtArticle>();//CtArticle文章数据类
List<Map<String, String>> projectList = new ArrayList<Map<String, String>>();
projectbeanlist = service.findAll();//从数据库中获取数据
projectList = service.toArrayList(projectbeanlist);
String str = "javascript:test(" + projectList.get(position).get("content").toString() + ")";
webview.loadUrl(str);
public ArrayList<Map<String, String>> toArrayList(List<CtArticle> list) {
ArrayList<Map<String, String>> mapList = new ArrayList<Map<String, String>>();
for (CtArticle data : list) {
try {
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", data.getId());
map.put("cid", data.getCid());
map.put("cidName", SystemUtil.showText(data.getCidName()));
map.put("FCid", data.getFCid());
map.put("FCidName", SystemUtil.showText(data.getFCidName()));
map.put("name", SystemUtil.showText(data.getName()));// 标题
map.put("isActive", data.getIsActive());
map.put("shareFrom", SystemUtil.showText(data.getShareFrom()));// 创建人
map.put("author", SystemUtil.showText(data.getAuthor()));// 出处
map.put("content", SystemUtil.showText(data.getContent()));// 内容
map.put("summary", SystemUtil.showText(data.getSummary()));//摘要
map.put("file1", data.getFile1());
map.put("img1", data.getImg1());
map.put("keyword", data.getKeyword());
map.put("hitNums", data.getHitNums());
map.put("postTime", data.getPostTime());
map.put("scorePeople", data.getScorePeople());
map.put("scoreAverage", data.getScoreAverage());
map.put("isRead", data.getIsRead());
map.put("isFavorite", data.getIsFavorite());
map.put("musicUrl", data.getMusicUrl());
mapList.add(map);
} catch (Exception e) {
Log.v(TAG,e.getMessage());
}
}
return mapList;
}
这样传到页面中的值是空的,projectList.get(position).get("content").toString()是字符串啊?要是换成指定的字符串file:///android_asset/content_loading.png或者“helloword”都是可以实现的,有没有遇到这种情况的,高手给点意见