Update ListView item outside of adapter
I have a ListView where each item represents a podcast. Selecting an item plays the podcast. While playing, the view for that ListView item displays an elapsed time counter with a SeekBar next to it to show progress.
Where I'm having a problem is figuring out how to handle updating the elapsed time counter (a TextView) while the SeekBar is being repositioned by touch. Calling notifyDataSetChanged
during the onProgressChanged
SeekBar event doesn't seem to work very well.开发者_如何学C
I'm not a huge fan of this UI pattern, simply because if the user scrolls, they may have difficulty finding where they were again. I would recommend having your SeekBar
and counter, plus information about the podcast currently playing, outside of the ListView
-- perhaps in a layout that is set to have visibility GONE
and is animated in when the user chooses a podcast.
Lacking that, I think you are in for a fair amount of coding pain.
You are correct that notifyDataSetChanged()
is probably not the answer. Instead, you will probably need to work with the TextView
directly...while it is on-screen. Tracking when it is and is not on-screen is the job of your Adapter
, though the details would vary significantly depending on how you are actually implementing the list (e.g., different view types for the rows?).
精彩评论