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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:16:08+00:00 2026-06-11T16:16:08+00:00

In Android 4.1 a, to me, seemingly strange error occurs in our app. In

  • 0

In Android 4.1 a, to me, seemingly strange error occurs in our app. In the app a custom adapter extending BaseAdapter is attached to a Gallery widget. When scrolling fast left-to-right and vice versa I get a FC with the exception message:

java.lang.IllegalArgumentException: Cannot draw recycled bitmap

Code for the getView(..) method is as follows:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;

    if (convertView == null){
        // View is not recycled. Inflate the layout.
        LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.gallery_image, parent, false);

        viewHolder = new ViewHolder();
        viewHolder.image = (ImageView) convertView.findViewById(R.id.gallery_image);

        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder)convertView.getTag();
        viewHolder.image.setImageDrawable(null);
    }

    imageLoader.displayImage(images.get(position).getFilename(),
            images.get(position).getUrlThumbnail(),
            viewHolder.image,
            Math.round(BitmapUtil.convertDpToPixel(400f, context)),
            Math.round(BitmapUtil.convertDpToPixel(400f, context)));

    return convertView;
}

I guess I should null the ImageView somewhere, but I cannot get it to work correctly. ImageLoader is a (quite) simple class for loading the images – either from LruCache, disk/sdcard or fetch it remotely.

  • 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-11T16:16:09+00:00Added an answer on June 11, 2026 at 4:16 pm

    It turns out that this error was caused by calling oldBitmap.recycle() in the entryRemoved(..) method in my class overriding LruCache. As the bitmap might still be attached to the ImageView calling recycle() will cause trouble.

    If I understand correctly: LruCache’s cache size will be set in its constructor. When the number of items exceeds this size the objects will be eligible for garbage collection, which will happen when the bitmap is no longer associated with an ImageView.

    A lot of examples and tutorials around the web suggest that recycle() should be called in entryRemoved(..), but from what I can see this is wrong.

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

Sidebar

Related Questions

I'm having a seemingly strange issue with my android app. Whether I call append
Possible Duplicate: Seemingly useless debugging environment for Android I've obviously been spoiled by Visual
Android Market app purchases have a 15-min grace period when a customer can cancel
Android's messaging app, located in projects/platform/packages/apps/Mms.git has a class called RecipientsEditor. I would like
I've adapted the GridInputProcessor class of the 3D-Gallery ( https://android.googlesource.com/platform/packages/apps/Gallery3D/+/master/src/com/cooliris/media/GridInputProcessor.java ) so that it
I can run and debug my Android app on my phone just fine, most
I had this question since android (seemingly) arbitrarily uses android2:... in some cases and
I'm trying to tackle a problem that seemingly many Android developers have, which is
It seems that the Android SDK doesn't compile my android app correctly. After building
I'm having some problem with developing an android app. Everything runs smooth until a

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.