首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

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

2012-03-25 
android listview 加图片和文字问题因为我做一个类围脖的系统,想在listview做图片和文字,但有些只有图片或

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()方法里改

热点排行