Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:44:06+00:00 2026-05-26T02:44:06+00:00

Main question: What is the most efficient bug free method of lazy loading remote

  • 0

Main question:

What is the most efficient bug free method of lazy loading remote images in a simple ListView adapter that utilizes the ViewHolder pattern?

I currently have an implementation that will first check a SoftReference Bitmap HashMap for a soft caches version of the image. If that fails I check my hard cache for a copy of the image. If that fails I get it from the web. I do all of this on a separate thread and in a queue to eliminate concurrent or duplicate downloads.

The problem is when loading through a callback. Because I utilize the ViewHolder pattern my views are constantly being recycled and I have not found a solid way to eliminate different images being randomly attached to my ImageViews. I do default to a default image before each load but because the views are being recycled so quickly “old” listeners apply onto my ImageView providing the wrong image which are then replaced with the correct image.

The only semi-solid solution I have found is to use the ViewHolder itself as the listener but this only makes the problem less apparent. It still happens on a fast scroll.

Any help would be appreciated.

Update:

https://github.com/DHuckaby/Prime

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:44:06+00:00Added an answer on May 26, 2026 at 2:44 am

    I have found a solution to the image switching problem and I will provide a code chunk below. I will not accept it yet though because I do not know if this is the most efficient method which is my original question. If this is implemented correctly it will work perfectly.

     public void getView(int position, View convertView, ViewGroup parent) {
    
         ViewHolder holder;
         if (convertView == null) {
    
         ...
    
         String imagePath = insertImageUrlHere();
         Object tag = holder.userThumb.getTag();
         if (tag != null && tag.equals(imagePath)) {
              // Do nothing
         } else {
              holder.userThumb.setTag(imagePath);
              holder.userThumb.setImageResource(R.drawable.default_image);
              AsynchronousImageLoadingUtility.load(imagePath, holder);
         }
    
         ...
    
         return convertView;
     }
    
     private static class ViewHolder implements AsynchronousImageLoadingUtilityCallback {
    
         private ImageView userThumb;
    
         @Override
         public void onImageLoad(String source, Bitmap image) {
              if (image != null && userThumb.getTag().equals(source)) {
                   userThumb.setImageBitmap(image);
              }
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question, is there a way to call your main method whatever you like
Very simple question, I made the following program : #include <stdlib.h> int main(int argc,
What is the most efficient way to split a string by a very simple
My question is what is the best and most efficient way to save a
The main question here is: is there a standard method of writing UNIX shell
My main question is given a feature centroid, how can I draw it in
The title is the main question. The exact scenario (I am 'using namespace std;'):
This was the main question posed by Greg Wilson's bits of evidence presentation. I'm
first of all, my main question: What are some good troubleshooting techniques when you
I am using Struts2, Spring 2 and Junit 4.5. My main question is, whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.