android listview 加图片和文字问题

phx120 2011-08-16 11:01:09
因为我做一个类围脖的系统,想在listview做图片和文字,但有些只有图片或只有文字,应该怎么做?

private ArrayList<String> commentNickname = null;
private ArrayList<String> sightComment = null;
private ArrayList<Bitmap> commentImage = null;

ArrayList<HashMap<String, Object>> commentList = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> map= null;
while(i<commentCount){
map= new HashMap<String, Object>();
map.put("picture", commentImage.get(i));
map.put("commentnickname",commentNickname.get(i));
map.put("sightComment", sightComment.get(i));
commentList.add(map);
i++;
}
SightAdapter listAdapter = new SightAdapter(this, commentList, R.layout.sightcommentlistview,
new String[] { "commentnickname", "sightComment","picture"},
new int[] { R.id.LVuserNameCO,R.id.LVsightComment,R.id.LVimageView});
setListAdapter(listAdapter);

几个arraylist都是从别地传过来的,里面可能有空,我需要一一对应,就是空的话就不显示,应该怎么办,不然会报错?
...全文
548 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
我解决了,有需要的告诉我。
  • 打赏
  • 举报
回复
解决了没,楼主?
解决了说一下啊,我也正发愁?
penghaoxi_1 2011-08-26
  • 打赏
  • 举报
回复
在adapter getview()方法里改

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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