How to start an activity after the animation has ended.
I have added android:oneshot=”true” in the xml but how to start a new activity
after this animation has stopped.I have attached the entire code below.
Please let me know how to start new activity.
package com.appsolut.example.animation;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class Animation extends Activity {
ImageView animation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onWindowFocusChanged (boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
AnimationDrawable frameAnimation =
(AnimationDrawable) animation.getBackground();
if(hasFocus) {
frameAnimation.start();
} else {
frameAnimation.stop();
}
}
public void onStart() {
{
super.onStart();
animation = (ImageView)findViewById(R.id.imageAnimation);
animation.setBackgroundResource(R.drawable.animation);
}
}
}
animation.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true" >
<item android:drawable="@drawable/img00000" android:duration="500" />
<item android:drawable="@drawable/img00001" android:duration="500" />
<item android:drawable="@drawable/img00002" android:duration="500" />
<item android:drawable="@drawable/img00003" android:duration="500" />
<item android:drawable="@drawable/img00004" android:duration="500" />
<item android:drawable="@drawable/img00005" android:duration="500" />
<item android:drawable="@drawable/img00006" android:duration="500" />
<item android:drawable="@drawable/img00007" android:duration="500" />
<item android:drawable="@drawable/img00008" android:duration="500" />
<item android:drawable="@drawable/img00009" android:duration="500" />
<item android:drawable="@drawable/img00010" android:duration="500" />
</animation-list>
Use and AnimationListener on your animation to do whatever you want on its
onAnimationEnd()method.