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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:56:08+00:00 2026-05-30T17:56:08+00:00

I am facing this issue but unable to resolve. My problem goes like this:

  • 0

I am facing this issue but unable to resolve. My problem goes like this:

  • I have a list view. My list row contains an image view and one text view
  • I have 20 images each of 12 MB size stored in my SD card
  • I have to set these images in imageView of my list view

I am able to do it by following code. This I am doing in getView method of my custom adapter:

public View getView (int position, View convertView, ViewGroup parent) {
    //other stuffs like recycling, view holder etc...
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inSampleSize = 4; // tried with 8,12 too
    Bitmap bitmap = BitmapFactory.decodeFile(imageUri, opt);
    holder.imageView.setImageBitmap(bitmap);
    return convertView;
}

Now this code works fine with small images but plays havoc for image of large size. Application crashes with OutOfMemoryError. If I try to increase inSampleSize to 8 or 12, it works but image quality drastically comes down and image doesn’t look original image at all. I tried with imageView.setImageURI(imageUri) also but documentation suggests to use setImageBitmap only.

Now please someone help me to rectify this issue. How can I resolve this without compromising with image quality?

  • 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-30T17:56:09+00:00Added an answer on May 30, 2026 at 5:56 pm

    Try setting inSampleSize to 2 or 4, and scale width and height down using the Matrix class.
    But as you said in another answer, this may hit performance.

    float desiredWidth = 60; // the width you want your icon/image to be
    float scale = desiredWidth/actualWidth // bitmap.getWidth() for actualWidth
    // float scale = desiredHeight/actualHeight // If you want to go by a particular height
    
    Matrix matrix = new Matrix();
    matrix.setScale(scale, scale);
    
    holder.imageView.setImageBitmap(Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false));
    bitmap.recycle(); // ish
    

    Second option. Before instantiating the Adapter class, get a Cursor object to thumbnail images and pass the cursor into the constructor of the adapter, making it a class varaible. Use the same cursor on every view row in the ListView.

    Uri tUri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI; // Where thumbnails are stored
    String[] columns = { MediaStore.Images.ImageColumns._ID,  MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.DISPLAY_NAME};
    
    Cursor thumbCursor = this.managedQuery(tUri, null, null, null, null); // May want to use more paramaters to filter results
    cursor.moveToFirst();
    
    .... instantiate adapter, pass in cursor ....
    
    public View getView (int position, View convertView, ViewGroup parent) {
    
    int columnIndex = cursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
    String filePath = cursor.getString(columnIndex);
    Bitmap bitmap = BitmapFactory.decodeFile(filePath);
    holder.imageView.setImageBitmap(bitmap);
    cur.moveToNext();
    // BitmapDrawable d = new BitmapDrawable(listActivity.getResources(), filePath);
    // holder.imageView.setImageDrawable(d);
    }
    

    Something like that. I did it in a hurry. Good luck =)

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

Sidebar

Related Questions

I'm facing this problem again and again, but can't find any solution (except mine,
I have created a static library following this link . But I am facing
I'm facing this issue when I'm calling AdMob ad with [rootController.view addSubview:adMobAd]; //setup the
I am facing this problem and finding solution for this issue since last 2
Can anyone guide me as I am facing this issue? I have a app
I was facing this unique problem of generating a bit-mask based on the input
A horizontal compass looks something like this if you are facing due East (90
I'm facing a problem with IE6. I took the toggle function from this website
I am facing a problem while creating a static cursor in DB2. This is
My development team of four people has been facing this issue for some time

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.