tags:

views:

31

answers:

1

I have a ListView where each item represents a podcast that can run up to 90 minutes. Selecting an item will display a SeekBar and start streaming in the audio from a URL using MediaPlayer.

I could use some pointers on how to handle maintaining the state of the SeekBar after it scrolls off the page and then scrolled back into view. I know that views are recycled and I've read that caching views in the adapter is a bad idea so I'm just wondering what other options there are.

A: 

I know that views are recycled and I've read that caching views in the adapter is a bad idea

It's a bad idea to cache all your Views, except via the recycling mechanism. Caching one SeekBar, or even a row containing a SeekBar, won't be that big of a problem. Caching 1,000 rows is where the trouble lies.

So, I'd note which position is the one for the playing podcast. In your getView() implementation in your adapter, if the requested position is the one for the playing podcast, use your cached row. Otherwise, go through normal recycling.

CommonsWare