I have been trying to implement Lazy Loading of images in Android. I have followed this excellent tutorial here: http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
The problem is it works perfectly fine in the emulator. In emulator the images load up but on real devices they just display the default image.
I have tested it on 6 android devices with no luck but they load perfectly on Emulator.
Any ideas on where i am going wrong?
Thanks in advance guys!
Edit: I have modified the code to use JSON Parsing rather than XML Parsing, if that matters.
My Lazy Adapter class:
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
// Toast.makeText(a, "here too", 500).show();
}
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);
TextView title = (TextView)vi.findViewById(R.id.title); // title
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(position);
// Setting all values in listview
title.setText(song.get("msg"));
imageLoader.DisplayImage(song.get("thumb"), thumb_image);
return vi;
}
}