一个关于webview加载本地html,执行js给页面传值为空

triplesky001 2013-11-12 10:02:51
如题,
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”都是可以实现的,有没有遇到这种情况的,高手给点意见
...全文
181 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
taogeDota 2014-10-11
  • 打赏
  • 举报
回复
参数格式的问题!我也遇到了,请问楼主如何解决的。
triplesky001 2013-11-12
  • 打赏
  • 举报
回复
结贴了,js的问题

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧