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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:56:05+00:00 2026-06-03T02:56:05+00:00

I’ve created a list of recipes using Listview/customcursoradapter. A custom layout includes a photo

  • 0

I’ve created a list of recipes using Listview/customcursoradapter. A custom layout includes a photo for the recipe , Now I’ve some problems with the performance of viewing and scrolling the ListView although it has only 10 records (Target is 150). Sometimes I get this error java.lang.OutOfMemoryError: bitmap size exceeds VM budget, I’ve tried to implement the AsyncTask but I failed to do it. Is there any way I can overcome this problem?

Your help is highly appreciated !!

Here is my getView method

public View getView(int position, View convertView, ViewGroup parent) {
    View row = super.getView(position, convertView, parent);
    Cursor cursbbn  = getCursor();
    if (row == null)
    {
        LayoutInflater inflater = (LayoutInflater) localContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.listtype, null);
    }

    String Title = cursbbn.getString(2);
    String SandID=cursbbn.getString(1);
    String Readyin = cursbbn.getString(4);
    String Faovoites=cursbbn.getString(8);

    TextView titler=(TextView)row.findViewById(R.id.listmaintitle);
    TextView readyinr=(TextView)row.findViewById(R.id.listreadyin);

    int colorPos = position % colors.length;
    row.setBackgroundColor(colors[colorPos]);

    titler.setText(Title);
    readyinr.setText(Readyin);

    ImageView picture = (ImageView) row.findViewById(R.id.imageView1);

    Bitmap bitImg1 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0001);
    Bitmap bitImg2 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0002);
    Bitmap bitImg3 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0003);
    Bitmap bitImg4 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0004);
    Bitmap bitImg5 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0005);
    Bitmap bitImg6 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0006);
    Bitmap bitImg7 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0007);
    Bitmap bitImg8 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0008);
    Bitmap bitImg9 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0009);
    Bitmap bitImg10 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0010);

    if(SandID.contentEquals("0001"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg1));

    if(SandID.contentEquals("0002"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg2));

    if(SandID.contentEquals("0003"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg3));

    if(SandID.contentEquals("0004"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg4));

    if(SandID.contentEquals("0005"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg5));

    if(SandID.contentEquals("0006"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg6));
    if(SandID.contentEquals("0007"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg7));
    if(SandID.contentEquals("0008"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg8));
    if(SandID.contentEquals("0009"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg9));

    if(SandID.contentEquals("0010"))
        picture.setImageBitmap(getRoundedCornerImage(bitImg10));

    return row;
}

And This is the error :

05-02 03:11:55.898: E/AndroidRuntime(376): FATAL EXCEPTION: main
05-02 03:11:55.898: E/AndroidRuntime(376): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:359)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:385)
05-02 03:11:55.898: E/AndroidRuntime(376):  at master.chef.mediamaster.AlternateRowCursorAdapter.getView(AlternateRowCursorAdapter.java:83)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.AbsListView.obtainView(AbsListView.java:1409)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.ListView.makeAndAddView(ListView.java:1745)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.ListView.fillUp(ListView.java:700)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.ListView.fillGap(ListView.java:646)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3399)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.AbsListView.onTouchEvent(AbsListView.java:2233)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.widget.ListView.onTouchEvent(ListView.java:3446)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.View.dispatchTouchEvent(View.java:3885)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
05-02 03:11:55.898: E/AndroidRuntime(376):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
05-02 03:11:55.898: E/AndroidRuntime(376):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
05-02 03:11:55.898: E/AndroidRuntime(376):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.os.Looper.loop(Looper.java:123)
05-02 03:11:55.898: E/AndroidRuntime(376):  at android.app.ActivityThread.main(ActivityThread.java:3683)
05-02 03:11:55.898: E/AndroidRuntime(376):  at java.lang.reflect.Method.invokeNative(Native Method)
05-02 03:11:55.898: E/AndroidRuntime(376):  at java.lang.reflect.Method.invoke(Method.java:507)
05-02 03:11:55.898: E/AndroidRuntime(376):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-02 03:11:55.898: E/AndroidRuntime(376):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-02 03:11:55.898: E/AndroidRuntime(376):  at dalvik.system.NativeStart.main(Native Method)
  • 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-03T02:56:06+00:00Added an answer on June 3, 2026 at 2:56 am

    First, you are not making use of convertView, you should start like,

    View view = convertView;
    if (view == null) {
      // inflate
    }
    

    here’s a blog post that talks about using convertView,

    http://android-er.blogspot.com/2010/06/using-convertview-in-getview-to-make.html

    Second, you should only decode the bitmaps for which you know you will use. so change your method like,

    if(SandID.contentEquals("0001"))
        Bitmap bitImg1 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0001);
        picture.setImageBitmap(getRoundedCornerImage(bitImg1));
    ...
    

    Third, can you decode them once, and have them available outside this method? for example, decode them once in the constructor and store them as instance members in your adapter class, then just use them in getView().

    Fourth, are you recycling your bitmaps? bitmaps are allocated differently than other objects and need to have their recycle() method called on them when you are finished using them. If you can implement the third item above, you can avoid this complexity for the most part, although you should still release them when your activity is stopped, re-allocate them when it’s started.

    There’s lots of good information on SO about Bitmap.recycle() and i’d recommend you spend some time researching it. Explaining the intricacies is beyond what can be accomplished in a post here. Here’s one good SO post covering the topic,

    Bitmap, Bitmap.recycle(), WeakReferences, and Garbage Collection

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

Sidebar

Related Questions

I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.