views:

47

answers:

1

Where should I start an AnimationDrawable that needs to animate when the activity is shown?

The developer guide recommends using onWindowFocusChanged, but this isn't always called when the activity is part of a TabHost.

I quote:

It's important to note that the start() method called on the AnimationDrawable cannot be called during the onCreate() method of your Activity, because the AnimationDrawable is not yet fully attached to the window. If you want to play the animation immediately, without requiring interaction, then you might want to call it from the onWindowFocusChanged() method in your Activity, which will get called when Android brings your window into focus.

A: 

The Activity's onResume() is always called when the Activity comes to the foreground. Try starting it in there.

Andy Zhang
Doesn't work. It seems the AnimationDrawable is not yet fully attached to the window.
hgpc