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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:42:49+00:00 2026-05-31T06:42:49+00:00

I was following this tutorial http://xjaphx.wordpress.com/2011/06/16/viewholder-pattern-caching-view-efficiently/ . however, it isnt working. Can you guys

  • 0

I was following this tutorial http://xjaphx.wordpress.com/2011/06/16/viewholder-pattern-caching-view-efficiently/. however, it isnt working. Can you guys help me how to make this working?

class Custom extends Activity {

 private ListView listview;
 private ArrayList mListItem;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
        setContentView(R.layout.custom);

  listview = (ListView) findViewById(R.id.list_view);
  mListItem = ItemsDisplay.getItems(true);

  listview.setAdapter(new CustomListAdapter(this, R.id.list_view,mListItem));
 }

 static class ViewHolder {
        public TextView textView;
    }

    private class CustomListAdapter extends ArrayAdapter {
        private ArrayList mList; //--CloneChangeRequired
        private Context mContext;

        public CustomListAdapter(Context context, int textViewResourceId,
                ArrayList list) { //--CloneChangeRequired
            super(context, textViewResourceId, list);
            this.mList = list;
            this.mContext = context;
        }   

        public View getView(int position, View convertView, ViewGroup parent) {
            View view = convertView;

            final ToggleButton tb;

             System.out.println("position "+position+" mList.size"+mList.size());
             if (view == null) {

              LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              view = vi.inflate(R.layout.list_item_bn, null);
              ViewHolder holder = new ViewHolder();
              holder.textView = (TextView)convertView.findViewById(R.id.tv_name);
              view.setTag(holder);
             }

             ItemsDisplay listItem = (ItemsDisplay) mList.get(position);
             System.out.println("listItem.getName() " +listItem.getName());
                if (listItem != null) {

                 ViewHolder holder1 = (ViewHolder)view.getTag();
                 holder1.textView.setText(listItem.getName());

                }

            return view;  
        }

    }
}

i already looked into these posts, but im not sure why my code still isnt working.
How to implement a view holder?
ListView with ArrayAdapter and ViewHolder adding icons to the wrong item

  • 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-31T06:42:51+00:00Added an answer on May 31, 2026 at 6:42 am

    change to:

            final ToggleButton tb;
    
             System.out.println("position "+position+" mList.size"+mList.size());
             if (convertView == null) {
    
              LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = vi.inflate(R.layout.list_item_bn, null);
              ViewHolder holder = new ViewHolder();
              holder.textView = (TextView)convertView.findViewById(R.id.tv_name);
              convertView.setTag(holder);
             }
    
             ItemsDisplay listItem = (ItemsDisplay) mList.get(position);
             System.out.println("listItem.getName() " +listItem.getName());
                if (listItem != null) {
    
                 ViewHolder holder1 = (ViewHolder)convertView.getTag();
                 holder1.textView.setText(listItem.getName());
    
                }
    
            return convertView;  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been following this tutorial: http://emumair.wordpress.com/2011/03/17/social-network-authentication-with-omniauth-and-authlogic/ . I've walked through it all and I'm
I'm following this tutorial http://mayurbirari.wordpress.com/2011/02/07/how-to-access-mkmapkit-in-iphone/ to set annotations on a map in my IOS
I am following this tutorial http://wicket.wordpress.com/2010/01/08/template-for-building-authenticated-webapplication/ in order to learn how to make login
I'm using CodeIgniter2 + Sparks + PhpActiveRecord, I installed following this tutorial : http://heybigname.com/2011/07/28/codeigniter-2-sparks-php-activerecord-part-1-installation/
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html I am following this as a guide to install subversion. The tutorial at
I'm following the barcode tutorial for this site: http://brismith66.blogspot.com/2010_07_01_archive.html using the google code: http://code.google.com/p/wsdl2objc/
I'm following this tutorial: http://railscasts.com/episodes/253-carrierwave-file-uploads or atleast I want to but would like to
I am following this tutorial: http://docs.djangoproject.com/en/dev/ref/contrib/messages/ but I get this error: Error: No module
I was following this tutorial : http://pronewb.com/mongodb-as-in-humongous-not-retarded . All was well until the I

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.