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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:41:15+00:00 2026-06-16T10:41:15+00:00

In a listview I want to draw one image on a list entry. These

  • 0

In a listview I want to draw one image on a list entry.
These 20 images have to scale to fill the width in vertical mode.
The phone resolution is 480 x 800 pixels (SGS2).
The images resolution is 400×400 and are about 100KB in size.
I’ve placed the images in the drawable folder.

When I scroll through the list it’s not going smooth.

I understand a few things:
– application Heap size = limited, Allocated when first run = 13MB, got 1 MB left.
– I have GC_FOR_ALLOC Log messages, which halts the system for 15ms. (this is my lagg in scrolling, I think).
– After changing the code I also see GC_CONCURRENT messages.

With these GC messages, I understand my garbage-collection kicks in every time I scroll to another image in a new listview entry.
This I can analyse so far, but I don’t know exactly what to do to fix and remove the GC permanently.
I have scaled down the images to 100×100 and it postpones the GC messages for a longer time.
But eventually the GC kicks in.
I do recycle the views with convertview, and use holders inside the views already.

I’ve read about re-using image memory, but not sure if and how I do this.
Or, maby it’s “normal” when using these larger images in a listview and I need to rethink the drawing of the images and only start drawing when the scolling ends?

Should I be using Listview for scrolling through pictures?

2012-12-31_02:11 I’ve implemented the setOnScrollListener, which makes scrolling smooth.
I think this is the piece of code I have to investigate further to butter things up.


listview adapter

public class ListviewAdapter extends BaseAdapter {

    private static Activity activity;
    private int[] data;
    private static LayoutInflater mInflater = null;

    public ListviewAdapter(Activity a, int[] d) {
        activity = a;
        data = d;
        mInflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return data.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.listviewitem, parent,
                    false);
            holder = new ViewHolder();

            holder.picture = (ImageView) convertView.findViewById(R.id.image);
            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        if (!MainActivity.isScrolling) {
    holder.picture.setImageResource(data[position]);
    }

        return convertView;
    }

    static class ViewHolder {
        ImageView picture;
    }

}

listview XML

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <ImageView
      android:id="@+id/image"
      android:src="@drawable/stub"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:contentDescription="Animal images"
        android:scaleType="fitCenter"
        android:scrollingCache="false"
        android:animationCache="false" 
        />

</LinearLayout>
  • 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-16T10:41:16+00:00Added an answer on June 16, 2026 at 10:41 am

    There are lots of techniques to make ListViews faster. See Efficient ListView in android. You should recycle Views, which will decrease Garbage Collection. You might also consider not loading Images before the list scrolling has stopped, see Lazy Load images on Listview in android(Beginner Level)?.

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

Sidebar

Related Questions

i have a ListView and i want to select one item from the list
I have a ListView and I want to specify the selection (item) mode. In
I have a listview with OwnerDraw = true and Details view mode. I want
I have a listview and I want to able to select one of the
I want to have a ListView that have an image in every item (star)
I have a ListView whereby I want to display one context menu if an
I want to draw some listview items disabled and would like to mimic the
I want to get conctacts on a listView and I want too reutilitzate one
i have the files situated in the listview now i want to copy those
I want to build my own listView with selectedItem and Itemsource. I have started

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.