2015-05-19 85 views
0

如何使用Universal Image Loader从URL加载图像? 我的HashMap:如何在SimpleAdapter中使用URL图像?

ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); 
HashMap<String, String> map = new HashMap<String, String>(); 
map.put("pict", "http://server/image"); 
map.put("name", "Name of the picture"); 
mylist.add(map); 

然后,我有SimpleAdapter:

ListView list = (ListView) findViewById(R.id.prod_listview); 
SimpleAdapter mSchedule = new SimpleAdapter(prod.this, mylist, R.layout.prod_rows, new String[] {"pict", "name"}, new int[] {R.id.prod_pict, R.id.prod_name}); 
list.setAdapter(mSchedule); 

我客串,我应该下载 'http://server/image',使其位图和一些神奇的方式把它放到SimpleAdapter。但是如何? 我看到通用图像加载程序,但我不知道如何在我的情况下使用它。

回答

0

是的,你必须使用这里Asynctask过程中下载图像,你有这个

Loading Image Asynchronously in Android

使用ImageDownloaderTask并在ImageView

if (holder.imageView != null) { 
      new ImageDownloaderTask(holder.imageView).execute(newsItem.getUrl()); 
     } 
+0

异步设置图像这个例子并不是一个例子使用SimpleAdapter :( –

相关问题