Android 实现ListView 文字+ 图片

1 ListView item 布局 



    
    

2 主显示页布局



    
    
        

        
        
    
    
    

        
            
                
                
            

        

        
        

3 文件+图片保存为List对象

//添加 > 图片
        ArrayList> dataList = new ArrayList>();
        for (int i =0;i<10;i++){
            Log.d("oldDocName", String.valueOf(oldDocName.get(i)));
            Map map = new HashMap();
            String string = (String) oldDocName.get(i).getOldDocName();
            //去掉后缀名
            String filename = string.substring(0,string.lastIndexOf("."));
            map.put("text",filename);
            map.put("pic",R.mipmap.go_launcher);
            dataList.add(map);
        }
        //适配器
        SimpleAdapter adapter = new SimpleAdapter(this, dataList,
                R.layout.item, new String[] { "text", "pic" },
                new int[] { R.id.DocName, R.id.DocName_tv });
        //ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_expandable_list_item_1, oldDocName);
        //实现列表的显示
        listView.setAdapter(adapter);

4 效果图

你可能感兴趣的:(Android,开发)