public class Mainpage extends Activity {
// Declaring an Image View and an Animation Drawable
ImageView view;
ImageView view1;
AnimationDrawable frameAnimation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
// Typecasting the Image View
view = (ImageView) findViewById(R.id.imageAnimation);
// Setting animation_list.xml as the background of the image view
view.setBackgroundResource(R.drawable.animation_list);
// Typecasting the Animation Drawable
frameAnimation = (AnimationDrawable) view.getBackground();
}
// Called when Activity becomes visible or invisible to the user
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// Starting the animation when in Focus
frameAnimation.start();
} else {
// Stoping the animation when not in Focus
frameAnimation.stop();
}
}
}
有没有什么方法可以停止帧动画并在那之后启动一个活动/意图?
我试图在谷歌上搜索这个查询,但大部分代码包括开始和停止按钮来停止帧动画......需要一个没有按钮的查询......帮助!