【发布时间】:2015-01-21 09:59:46
【问题描述】:
我正在尝试在 SimpleAdapter 列表视图中显示图片。我在我的项目中加入了 Picasso,但我不知道如何将 Picasso 与 SimpleAdapter 一起使用。
List<HashMap<String, String>> featured = new ArrayList<HashMap<String, String>>();
for (int i=0;i<ids.length;i++){
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("productname", names[i]);
hm.put("productprice", prices[i]);
hm.put("productimage", images[i]);
featured.add(hm);
}
String[] from = {"productname", "productprice", "productimage"};
int[] to = {R.id.tv_ProductName, R.id.tv_ProductPrice, R.id.icon};
SimpleAdapter adapter = new SimpleAdapter(MainActivity.this, featured, R.layout.listitem_featured, from, to);
HorizontalListView featuredList = (HorizontalListView) findViewById(R.id.lv_Featured);
featuredList.setAdapter(adapter);
产品名称和价格显示正确。根本不显示产品图像。图片是url,例如:
http://thingd-media-ec1.thefancy.com/default/171510088920465761_1686d73fc160.jpeg
如何正确显示图像?
【问题讨论】:
标签: java android android-listview picasso simpleadapter