I am using the Android-Universal-Image-Loader library to upload deleted images to ImageView in GridView cells.
Here's the imageLoader configuration:
new ImageLoaderConfiguration.Builder(Config.context) .threadPriority(Thread.NORM_PRIORITY - 2) .memoryCacheSize(20 * 1024 * 1024) // 20 Mb .memoryCache(new LruMemoryCache(20 * 1024 * 1024)) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .tasksProcessingOrder(QueueProcessingType.LIFO) .enableLogging() // Not necessary in common .build();
and display options:
new DisplayImageOptions.Builder() .showStubImage(R.drawable.blank) .showImageForEmptyUri(R.drawable.no_image) .build();
Problems: When activity starts with gridview, everything works correctly, and the images appear in the cells, then I scroll down the grid (I have about 20 elements in the grid), and other images load properly. But as soon as I scroll up, images that have already downloaded will start to load again.
After several scrolls up and down, the grid saves all the images and they no longer disappear.
Someone has encountered similar problems, or you know what I did wrong. Thanks for the help.
ADDED : Here is the getView method in my adapter:
@Override public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView; ViewHolder holder; if ( view == null ) { view = Config.context.getLayoutInflater().inflate(R.layout.featured, null); holder = new ViewHolder(); holder.titleText = (TextView) view.findViewById(R.id.featured_title); holder.priceText = (TextView) view.findViewById(R.id.featured_price); holder.image = (ImageView) view.findViewById(R.id.thumbnail_image); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } HashMap<String, String> listing = listings.get(position); holder.titleText.setText(listing.get("title")); holder.priceText.setText(listing.get("price")); Utils.imageLoaderFeatured.displayImage(listing.get("photo"), holder.image, Utils.imageLoaderOptionsFeatured); return view; }
PS. Let me know if you want to see another code (maybe a network adapter) to help me with this problem.
John
android image universal-image-loader loader universal
John f
source share