I am currently using a custom adapter to display an ImageView and two TextViews per row in a ListView.
Within the overridden getView for the adapter, I have this code for the ImageView:
final ImageView img = (ImageView) view.findViewById(R.id.rowImg);
new Thread(new Runnable() {
public void run() {
final BitmapDrawable b = downloadAvatar(urlToDownload);
img.post(new Runnable() {
public void run() {
img.setImageDrawable(b);
}
});
}
}).start();
The downloadAvatar method basically just uses AndroidHttpClient and HttpGet. The above method works, but my question is how do I optimize it? Scrolling is choppy; I know it's probably calling getView() and downloading the image each and every time it enters the viewable area. Any tips?