2012-01-28 19 views
0

我有一张照片Uri和我想要在ListView中显示它,我该怎么做? 这里是我的代码如何在Uri中显示ListView中的图像

Uri img = getImgByContactId(Long id); 
map.put("imgcontact", ???? img ??????); 
map.put("date", "20/2010"); 
map.put("duration", String.valueOf(duration)); 
map.put("type", finalTypeImg); 

SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.calllogtemplate, 
    new String[] {"num", "name", "imgcontact", "date", "duration", "type"}, 
    new int[] {R.id.num, R.id.name, R.id.imgcontact, R.id.date, R.id.duration, R.id.typecall}); 

ListView maListViewPerso = (ListView) findViewById(android.R.id.list); 
maListViewPerso.setAdapter(mSchedule); 

感谢

+0

编写自己的适配器,它扩展了ArrayAdapter,然后在getView()中自己处理图像,并使用你的uri将其设置为imageview。 – Blundell 2012-01-28 00:23:56

回答

0

看看这个适配器,应该保存你的工作了几个小时:https://github.com/tbiehn/Android-Adapter-Image-Loader

+0

@ user1162759如果任何一个答案对您有帮助,请考虑接受它[通过推动旁边的复选标记]。 SO的声誉系统取决于你这样做:) – 2012-01-30 15:33:19

0

使用可绘制setImageUri(URI),然后setDrawable在您的ImageView。在您的适配器的getView()内的ViewHolder中使用ImageView。请阅读BaseAdapter。希望它有助于提高。 Cheers

相关问题