On Thu, Apr 22, 2010 at 3:38 PM, scp89 <[email protected]> wrote:
> They should change right away, since that code is first. Can someone > explain why this is and how to prevent it? > Although you call setText first, you won't actually see that reflected on the screen until the system does a render pass on the view. This happens on the main thread. Unfortunately you're also calling the Music.playSong on the main thread, which *blocks* until it's finished, then allows the main thread to continue. Only then does the render pass complete at which point you see the text changed. So the order of execution is something like this: - request change in text (does not actually change view) - load song (process, download, buffer, whatever, it takes time) - system refreshes display with new text set in the first call I hope that makes sense. I want the textview and seekbar to change right away so the user has some > feedback when they click, otherwise it looks like nothing happens for a few > seconds while the song is loading. > You'll want to put the music loading in a separate thread, or use Android's threading facilities to simplify this (AsyncTask for example). HOWEVER - since you said you new to Java it is HIGHLY recommended you learn that first independently of Android. If you try to do both, after you already got stuck on a classic threading problem, you are setting yourself up for a lot of frustration. Good luck. ------------------------------------------------------------------------------------------------- TreKing - Chicago transit tracking app for Android-powered devices http://sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

