0
 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();
        }
    }

 }

有没有什么方法可以停止帧动画并在那之后启动一个活动/意图?

我试图在谷歌上搜索这个查询,但大部分代码包括开始和停止按钮来停止帧动画......需要一个没有按钮的查询......帮助!

4

1 回答 1

0

YesframeAnimation.stop();方法用于停止动画。对于新的开始Activity,您可以使用以下代码-

startActivity(Mainpage.this, newActivity.class);

或者

Intent i = new Intent(this, newActivity.class);
startActivity(i);

您可以使用Activity要开始的名称来代替newActivity.

于 2013-10-06T17:56:00.077 回答