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 9194767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:29:26+00:00 2026-06-17T21:29:26+00:00

I have a custom ImageView subclass that I am using to fetch images in

  • 0

I have a custom ImageView subclass that I am using to fetch images in URL using an AsyncTask. However it seems that no matter what I do, the list view population is paused until the image is fetched.

public void setImageURL(final String url) {
    // do we have url in the cache?
    Bitmap bitmap = mCache.getBitmap(url);
    if(bitmap == null) {
        new AsyncTask<Void, Void, Bitmap>() {
            protected Bitmap doInBackground(Void... p) {
                Bitmap bm = null;
                try {
                    URL aURL = new URL(url);
                    URLConnection conn = aURL.openConnection();
                    conn.setUseCaches(true);
                    conn.connect();
                    InputStream is = conn.getInputStream();
                    BufferedInputStream bis = new BufferedInputStream(is);
                    bm = BitmapFactory.decodeStream(bis);
                    bis.close();
                    is.close();
                } catch(IOException e) {
                    e.printStackTrace();
                }

                if(bm == null) {
                    return null;
                }
                return bm;
            }

            protected void onPostExecute(Bitmap bmp) {
                if(bmp == null) {
                    return;
                }
                mCache.cacheBitmap(url, bmp);
                setImageBitmap(bmp);
            }
        }.execute();
    } else {
        setImageBitmap(bitmap);
    }
}

Why should an async task block anything to do with the list population?

  • 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-06-17T21:29:28+00:00Added an answer on June 17, 2026 at 9:29 pm

    Are you starting multiple AsyncTasks? I would implement it to only use 1 AsyncTask that loads all images. A lot of time will be spent allocating and starting new Threads for each image.

    http://developer.android.com/training/displaying-bitmaps/process-bitmap.html will get you started. However be sure to account for things like how a ListView reuses views as it scrolls. You don’t always have a simple 1 view to 1 bitmap pair.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView whose cells contain custom ImageViews that asynchronously load the images
In my iPhone application I have a tableview with custom imageview and loading images
I have a custom ListView and an ImageView that I'm trying to use as
I have a custom list view with the following item layout: <?xml version=1.0 encoding=utf-8?>
I have a custom class that I've written that extends ImageView (for Android Java).
I have a custom view (an extension of a TextView) that I want to
I have a custom ListView that does a lazy load of remote images. When
I have a custom class that extends ImageView public class MyCompass extends ImageView {
I have a custom notification that uses a LinearLayout that contains an ImageView and
I have a Custom ListView which has an ImageView and a TextView. and i

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.