I Create a Activity Extends ListActivity I can used SimpleAdapter to display R.drawable.picture but I want to display picture from web in CustomerItem How do?
List
Override
the setViewImage
in SimpleAdapter
and load the image url, in optimized way.
@Override
public void setViewImage(final ImageView v, final String value) {
new AsyncTask() {
@Override
protected InputStream doInBackground(Void... params) {
try {
return new URL(value).openConnection().getInputStream();
} catch (Exception ex) {
// handle the exception here
}
return null;
}
@Override
protected void onPostExecute(InputStream result) {
if(result != null) {
Bitmap bitmap = BitmapFactory.decodeStream(result);
v.setImageBitmap(bitmap);
}
}
}.execute();
}