I'm tring to receive a bitmap image from web and show it on list view's item which contain image view.
But this seems got a trouble in setting image to Bitmap Object "bmImage".
How can i copy received bitmap and return it?
public class DownloadListImageTask extends AsyncTask<String, Integer, Bitmap> {
Bitmap bmImage;
public DownloadListImageTask(Bitmap bmImage){
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls){
String url = urls[0];
Bitmap bitmap = null;
try{
InputStream in = new URL(url).openStream();
bitmap = BitmapFactory.decodeStream(in);
}catch(Exception e){
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap result){
bmImage = result.copy(result.getConfig(), true);
}
}
following is a useage
Bitmap bitmap;
new DownloadListImageTask(bitmap).execute(url);
adapter.addItem(bitmap);