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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:44:06+00:00 2026-05-25T10:44:06+00:00

I have a CustomCursorAdapter to do the nice section headers. I removed all images

  • 0

I have a CustomCursorAdapter to do the nice section headers. I removed all images from the ListView rows but the scrolling is still rather laggy. Anyone knows a way to optimize this? The scrolling on applications like Viber for Contacts is really smooth even for 2000 contacts. Thanks!

public View getView(int position, View convertView, ViewGroup parent) {
    final int type = getItemViewType(position);
    if (type == TYPE_HEADER) {
        if (convertView == null) {
            final LayoutInflater inflater = LayoutInflater.from(context);
            convertView = inflater.inflate(R.layout.list_header, parent,
                    false);
        }
        ((TextView) convertView.findViewById(R.id.list_header_title))
                .setText((String) getSections()[getSectionForPosition(position)]);
        return convertView;
    } else {
        View v = super.getView(
                position
                        - sectionToOffset
                                .get(getSectionForPosition(position)) - 1,
                convertView, parent);

        int contactIdCol = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID);

        String contactId_text = c.getString(contactIdCol);

        boolean flag = db.isRegistered(contactId_text);

        ImageView iv = (ImageView) v.findViewById(R.id.typeImage);
        if (flag) {
            iv.setImageResource(R.drawable.rocket);
        } else {

            iv.setMinimumHeight(Config.getIconSize(context));
            iv.setMinimumWidth(Config.getIconSize(context));
            iv.setImageDrawable(null);
        }

        ImageView iv1 = (ImageView) v.findViewById(R.id.test);

        cl.displayImage(contactId_text, iv1);

        return v;
    }

}

To further clarify, it’s the fast scrolling that is jerky, the normal scroll seems fine.

  • 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-25T10:44:07+00:00Added an answer on May 25, 2026 at 10:44 am

    You are creating a list view item every time “getView” is called. A good way to gain performance is to create a static “viewHolder” class wich represents the data of a view item.

    e.g.

    static class ViewHolder
    {
        ImageView icon;
        TextView title;
    }
    

    in the “getView” method you can create an instance of the viewHolder then:

        if (convertView == null) {
    
            final LayoutInflater inflater = LayoutInflater.from(context);
    
            convertView = inflater.inflate(R.layout.list_header, parent, false);
    
            holder = new ViewHolder();
            holder.icon = (ImageView) convertView.findViewById(R.id.icon);
            holder.name = (TextView) convertView.findViewById(R.id.title);
            convertView.setTag(holder);
    
        }
    

    and then fill the data of your holder:

    if (item != null) {
        holder.title.setText("ItemTitle");
        holder.icon.setImageResource(R.drawable.rocket);
    }
    
    return convertView;
    

    for a detailled example see also:

    http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html

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

Sidebar

Related Questions

i'm making a listview ,but scrolling is too slow. i have a ImageButton and
I have a listView with custom rows containing buttons and I populate the listView
i have a listview with checkbox in each rows. i'm using custom cursoradapter and
Have converted devise new session from erb to Haml but doens't work, this is
Have a rather abstract question for you all. I'm looking at getting involved in
I have a database, a ListView , and a CustomCursorAdapter that extends CursorAdapter .
I have a ListView with a custom CursorAdapter feed from a MatrixCursor . Each
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
I have a custom CursorAdapter that is taking items from a database and displaying
Have a LinqtoSql query that I now want to precompile. var unorderedc = from

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.