im looking for an example code, my xml is fine, i want to start the animation right when the activity is started, not pressing anything
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class AnimationActivity extends Activity
{
ImageView genie;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
genie = (ImageView)findViewById(R.id.genieout);
genie.setBackgroundResource(R.drawable.genieani);
genie.post(new Runnable() {
@Override
public void run() {
AnimationDrawable genieout =
(AnimationDrawable) genie.getBackground();
genieout.start();
}
});
}
1 Answer