这是我尝试过的:
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<len;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("tit", "Title : " + title[i]);
hm.put("init","Initial Price : " + cur_price[i]);
hm.put("cur","Current Price : " + init_price[i]);
hm.put("img", bitmap[i].toString() );
aList.add(hm); //I'm getting an error here
}
// Keys used in Hashmap
String[] from = { "tit","init","cur","img"};
// Ids of views in listview_layout
int[] to = { R.id.tit,R.id.init,R.id.cur,R.id.img};
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(),
aList, R.layout.listview_layout, from, to);
ListView listView = ( ListView ) findViewById(R.id.listview);
listView.setAdapter(adapter);
}
我认为使用Bitmap分配一个imageview,可能会使用类似的东西:
ImageView logoimg = (ImageView) findViewById(R.id.logo);
logoimg.setImageBitmap(bitmap);
1)但是我怎样才能在SimpleAdapter中做同样的事情?
2)此外,为什么我在HashMap的add()方法中出错?