I have 400 images in my server database. I am able to get those images and display in my emulator. But it is taking lot of time to get the image from server. Hence I want to get the image asynchronously. How can I achieve that task? Help me regarding this…Will be thankful in advance….
I want to convert the following code to asynchronous task….
My Code:
public View getView(.......)
{
ImageView myimgview = (ImageView) view.findViewById(R.id.imageView100);
drawable = LoadImageFromWebOperations(v.getTag().toString());
myimgview.setImageDrawable(drawable);
---
---
---
}
private Drawable LoadImageFromWebOperations(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "image.png");
return d;
}
catch (Exception e)
{
System.out.println("Exc=" + e);
return null;
}
}
You can use a thread in combination with a handler:
Where getDrawable is your function to get images synchronously.