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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:23:22+00:00 2026-06-13T13:23:22+00:00

I have a bit troublesome with view caching in listview (a.k.a convertView) so here

  • 0

I have a bit troublesome with view caching in listview (a.k.a convertView)
so here is my code,

private class CurrencyAdapter extends ArrayAdapter<CurrencyModel> {
    Context ctx;
    int layoutResourceId;
    List<CurrencyModel> adapter_models = null;

    public CurrencyAdapter(Context ctx, int layoutResourceId,
            List<CurrencyModel> model) {
        super(ctx, layoutResourceId, model);
        this.ctx = ctx;
        this.layoutResourceId = layoutResourceId;
        adapter_models = model;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        Log.d(Constants.APP_TAG, "position: " + position);
        View row = convertView;
        CurrencyAdapterContainer holder = null;
        if (row == null) {
            Log.d(Constants.APP_TAG, "APP NULL");
            row = ((Activity) ctx).getLayoutInflater().inflate(
                    layoutResourceId, parent, false);
            holder = new CurrencyAdapterContainer();
            holder.textView = (TextView) row
                    .findViewById(R.id.currencies_txt);
            holder.imgView = (ImageView) row
                    .findViewById(R.id.currencies_flag_icon);
            row.setTag(holder);

        } else {
            Log.d(Constants.APP_TAG, "APP NOT NULL");
            holder = (CurrencyAdapterContainer) row.getTag();
        }

        CurrencyModel curr = getItem(position);

        if (curr.currency_value == null) {
            if (counter < MAX_COUNTER) {
                ++counter;
                CurrencyJsonDownloader cDownloader = new CurrencyJsonDownloader(
                        curr, holder.textView);  //download currency value in background, and set textview text if currency_value has been loaded in onpostExcecute (i'm using AsyncTask)
                String url = CURRENCY_URL.replace("<symbol>", curr.symbol);
                Log.d(Constants.APP_TAG, "Url currency: " + url);
                cDownloader.execute(url);
            }
            holder.textView.setText("");
        } else {
            holder.textView.setText(curr.currency_value);
        }
        holder.imgView.setImageResource(curr.drawableId);

        return row;
    }

    @Override
    public CurrencyModel getItem(int position) {
        // TODO Auto-generated method stub
        return adapter_models.get(position);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return adapter_models.size();
    }
}

static class CurrencyAdapterContainer {
    ImageView imgView;
    TextView textView;
}

and here is the output in my logcat

position : 0
APP NULL

position : 1
APP NOT NULL

position : 2
APP NOT NULL

position : 3
APP NOT NULL

.
.
.

position : 10
APP NOT NULL

which make a disaster because it means that the textview being passed in the background job is the same textview and the the changed view is the same textview and the other textview will have blank view unless i scroll it of course which call again the getView() and everything is fine. But it’s a problem when starting the app, because just one textview that always changing its value.

so why is this happen? and is there any hack that i can do??
thanks before…

  • 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-13T13:23:23+00:00Added an answer on June 13, 2026 at 1:23 pm

    ListView item Views are recycled, so never hold a reference to a particular item view and expect it to represent same data after ListView has been scrolled.

    Pass the data item to your worker task instead and let it update the data to it.

    Updating:

    • If your current item is off screen, It’ll be requested from adapter (
      when ListView scroll to it), and will show updated data.
    • If that item is currently being displayed , call notifyDataSetChanged() on adapter, this will make ListView refresh its displayed items.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a bit of confusion here. I added a few objects from a class
i have bit of code that causes an underflow: var t1, t2, delta: DWORD:
I have a bit of code that fits theoretical prediction to experimental data, and
I have a bit of a problem that I can't seem to code my
I have a bit of a problem around here, I just can't get it
I have this bit of code: [self.vManager playersNearLocation:userLocation block:^(NSSet *players, NSError *error) { if(players
Have a bit of code ported from VB6 to VB.NET. It uses Write and
i have this bit of html. (Link at bottom) Its output of php code
We have a bit of an issue here. We have upgraded from Delphi 2006
I have this bit of code where it displays some locations from an XML

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.