2012-01-28 17 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

相關問題