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

  • Home
  • SEARCH
  • 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 8667919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:05:04+00:00 2026-06-12T18:05:04+00:00

I always use ViewHolder pattern in my custom ArrayAdapter classes. However, in CursorAdapter the

  • 0

I always use ViewHolder pattern in my custom ArrayAdapter classes. However, in CursorAdapter the getView() method is not mandatory required to be overridden , but has the bindView and newView methods.

My question is – does CursorAdapter re-uses views by internally implementing the ViewHolder pattern or it needs to be coded as we normally do in custom ArrayAdapter? If it needs to be coded, what is the correct way to do it?

Update

I’m using android.support.v4.widget.CursorAdapter

  • 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-12T18:05:06+00:00Added an answer on June 12, 2026 at 6:05 pm

    My question is – does CursorAdapter re-uses views by internally
    implementing the ViewHolder pattern or it needs to be coded as we
    normally do in custom ArrayAdapter?

    I’m not sure at what do you refer by the ViewHolder pattern. If you are referring to having a helper class to cache looking for view each time(and setting it as a tag for the row View) then the answer is no. If you want to implement this pattern you’ll need to setup the holder(look for the views in the row view with findViewById) in the newView method and then set it as the tag for the row view. Then in the bindView method you can call getTag, retrieve the holder and use it. An example:

    // custom CursorAdapter ...
    
        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent) {
            View rowView = ((LayoutInflater) context
                    .getSystemService("layout_inflater")).inflate(
                    R.layout.row_layout, parent, false);
            ViewHolder holder = new ViewHolder();
            holder.v1 = rowView.findViewById(R.id.v1);
            holder.v2 = rowView.findViewById(R.id.v2);
            rowView.setTag(holder);
            return rowView;
        }
    
        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            ViewHolder holder = (ViewHolder) view.getTag();
            // use the holder filled with views
            // hlder.v1.setSomething
        }
    
        class ViewHolder {
            View v1, v2;
        }
    // ...
    

    If you are referring to the convertView being reused(like in non Cursor based adapters) then the answer is yes, the getView method implements this pattern, you just need to implement the newView and bindView methods and you’re guaranteed to get a view which was recycled(if possible at that moment).

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

Sidebar

Related Questions

Pep8 advises to always use cls as the first argument of a class method
Should timestamps always use UTC (as in 2012-06-14T10:32:11+00:00 ) and not local time (as
I always use the Post/Redirect/Get method on my forms. My forms generally always submit
I've heard people advise that one should always use the Iterator pattern to control
I always use Jave EE 6 framework for web application. So I am not
I always use this method to easily read the content of a file. Is
I always use the same folder structure in my projects (includes/ classes/ style.css index.php)
Possible Duplicate: Why we always use <ul> to make Navigation why not <ol> ?
I used to always use tables. However, I've been told that the use of
In almost all my classes I use properties and I always use retain properties

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.