Web xml ファイルからデータを読み込んでおり、画像も Web から読み込んでいます。画像をビットマップ bmImg として取得し、ハッシュマップに入れました。しかし、その画像を imageView に表示するように simpleAdapter 関数を変更する方法は知っています。私はここで立ち往生しており、研究プロジェクトを行っています。助言がありますか?
これはコードです:
NodeList ノード = doc.getElementsByTagName("製品"); for (int i = 0; i < nodes.getLength(); i++) {
HashMap<String, Object> map = new HashMap<String, Object>();
Element e = (Element)nodes.item(i);
Bitmap bmImg = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://licrp.dnsalias.net:8000/iteam/images/" + GetXML.getValue(e, "ImagePath"));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
BufferedHttpEntity b_entity = new BufferedHttpEntity(httpEntity);
InputStream input = b_entity.getContent();
bmImg = BitmapFactory.decodeStream(input);
} catch (MalformedURLException e1) {
} catch (IOException e1) {
}
map.put("id", GetXML.getValue(e, "id"));
//map.put("ProductName", "Product Name:" + GetXML.getValue(e, "ProductName")); Example
map.put("ProductName", GetXML.getValue(e, "ProductName"));
map.put("Desc", GetXML.getValue(e, "Desc"));
map.put("Price", GetXML.getValue(e, "Price"));
map.put("ImagePath", bmImg);
mylist.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(this, mylist , R.layout.lbsdetailviewmain,
new String[] { "ProductName", "Desc","Price","ImagePath" },
new int[] { R.id.product_name, R.id.desc , R.id.price,R.id.image1});
setListAdapter(adapter);
final ListView lv = getListView();
lv.setTextFilterEnabled(true);