专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Eclipse

android listview 加图片和文字有关问题

发布时间:2010-06-05 15:35:48 文章来源:www.iduyao.cn 采编人员:星星草
android listview 加图片和文字问题
因为我做一个类围脖的系统,想在listview做图片和文字,但有些只有图片或只有文字,应该怎么做?
Java code

    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都是从别地传过来的,里面可能有空,我需要一一对应,就是空的话就不显示,应该怎么办,不然会报错?

------解决方案--------------------
在adapter getview()方法里改
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: