0

I have a listadapter as an inner class of my activity. Inside of the getView() I inflate a layout file which has a few different views inside of it. I save one of those views (a progress bar) to a

Map<String,ProgressBar> progBars 

which is defined in my activity. Later I want to update the progress bar when I click a button. So I find the progress bar,

ProgressBar pb = progBars.get("key");

Now I specifically check

if(pb!=null) 

and it is NOT null. I try to set the progress on it and nothing changes. BUT if I go to a new activity and then come back OR if I go back to the previous activity (back button) and then return to this one and I click the button the progress bar correctly updates to the value. This makes absolutely no sense to me. Any thoughts?

pat
  • 1,005
  • 4
  • 12
  • 29

1 Answers1

0

DO NOT try to cache views used by ListAdapters. ListView, GridView, and other AdapterViews automatically recycle views that get scrolled off screen.

Please watch this video: The World of ListView

Karakuri
  • 38,365
  • 12
  • 84
  • 104
  • I'm pretty familiar with not caching views in listadapter. In this code I am only saving the progress bars of the first 5 or so rows. Any other thoughts on how to accomplish this instead? This also doesn't explain why it does work when I leave the activity and come back... – pat Aug 03 '13 at 02:11