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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:08:17+00:00 2026-05-28T00:08:17+00:00

I have a straight forward BaseAdapter for my ListView. It downloads a JSON feed

  • 0

I have a straight forward BaseAdapter for my ListView. It downloads a JSON feed and displays the data in the rows. There is a ViewHolder which contains the views and a data object called “Story”. Everything works just fine.

However, after some scrolling of longer lists, I notice two things.

1) My log shows that the adapter is reloading the feed when scrolling further down. This is strange, as I put the whole JSON array into a variable, so why does it have to reload?

2) More importantly, after some scrolling back and forth, the rows contain the wrong “Story” objects. Here are the relevant parts of the getView routine:

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    Story story = stories.get(position);
    if (convertView == null) {
        //create holder
        holder = new ViewHolder();
        convertView = inflator.inflate(R.layout.story_list_item, parent, false);
        holder.titleView = (TextView) convertView.findViewById(R.id.story_list_title);
        holder.dateView = (TextView) convertView.findViewById(R.id.story_list_date);
        holder.story = story;
        holder.imageView = (ImageView) convertView.findViewById(R.id.story_list_image);
        convertView.setTag(holder);
        } else  {
            holder = (ViewHolder) convertView.getTag();
        }       
    // configure the view       
    holder.titleView.setText(story.title);
    return convertView;
}

Simple enough. Now the strange thing is that I can fix the problem by eliminating the if statement if (convertView == null) (and, I presume, eliminating the row recycling as well).

But will I not run into memory problems this way? Why does the plain vanilla version not work?

Thanks for your help.
Regards,
S

  • 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-28T00:08:17+00:00Added an answer on May 28, 2026 at 12:08 am

    You are aware that you’re only assigning

    holder.story = story 
    

    when convertView == null ? Consider moving holder.story = story to just after your convertView if-case and it should work a lot better. Btw, do you even need to store the “story” inside your view holder? Typically that pattern should only be used to store Views and view state information, not the data of the actual position.

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

Sidebar

Related Questions

I currently have a fairly straight forward UI which displays three 250 x 180
Just a straight forward problem. I have a LinearLayout which has attribute in xml
I have a minimum age custom validator which is straight forward enough: The constraint(Minage.php)
I have a question which i suspect is fairly straight forward. I have the
I have an object which straight forward instance variables. Some are NSString, some are
Have a pretty straight forward SSIS package: OLE DB Source to get data via
Hey there, I have a probably straight-forward question about the following problem: I have
I have this very straight forward question regarding Thread and Timer classes in Java
I have a pretty straight forward task - Given the URL of a video,
I have an nHibernate query issue that looks quite straight forward, but I can't

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.