I have a listview that displays an image and a text from internet.
My intention is that this image, in addition to showing a imageview, is the background image of listview row.
This works but with problems.
In the listview adapter I have for the imageview:
imageLoader.DisplayImage (song.get (principal.KEY_PICTURE) my_imageView);
and to use the image in the LinearLayout:
imageLoader.DisplayImageLinear (song.get (principal.KEY_PICTURE) my_linearLayout);
This calls the following method:
public void DisplayImageLinear (String url, LinearLayout linearbck)
{
Bitmap bitmap = memoryCache.get (url);
Drawable d = new BitmapDrawable (bitmap);
if (bitmap! = null) {
linearbck (d);
}
else
{ linearbck.setBackgroundResource (R.drawable.list_selector); }
}
My problem is that the background images of the rows of the listview are only visible when the listview slip and rows out of the screen and re-enter …
I hope I’m explaining correctly .. here a picture explaining the problem

I tried to use linearbck.invalidate (), but without success
I sincerely appreciate any help
thanks
Best regards
EDIT:
add the adapter. Thanks 🙂
public class lstAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public MinAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_row, null);
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image);
ImageView photo_user =(ImageView)vi.findViewById(R.id.photoUser);
LinearLayout background =(LinearLayout)vi.findViewById(R.id.background);
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(position);
imageLoader.DisplayImage(song.get(principal.KEY_AVATAR_AUTOR_ENTRADA), thumb_image);
imageLoader.DisplayImage(song.get(principal.KEY_PICTURE), photo_user);
imageLoader.DisplayImageLinear(song.get(principal.KEY_PICTURE), background);
return vi;
}
@Override
public boolean isEnabled(int position)
{
if(principal.asynTaskEnUso.equals("yes")){
return false;
} else {
return true;
}
}
}
We when we see the source of
ImageLoader, when there is no photo downloaded in cache, it queues the photo.=> You are not queuing the photo.
When photo is downloaded, it is set to the ImageView, from the callback.
=>You may (or most probably) not be setting it to the
LinearLayoutas background.Now your problem:
For the first time, cache is empty, it doesn’t find required photo, so it goes and put it to download, since you have not implemented and queued for the
LinearLayoutto set as background in the callback. it doesn’t shown, but when you scrollListViewand get back, it finds the image for the first time (because it was downloaded and cached) and set it as background.Solution:
Maintain and set some flags to Keep track of your
LinearLayout‘s reference and while download completed set it as background.