gpt4 book ai didi

java - 可绘制动画结束时进入新 Activity

转载 作者:太空宇宙 更新时间:2023-11-04 15:20:29 24 4
gpt4 key购买 nike

您好,我尝试在 Drawable animaition 完成后启动一个 Activity ,但我无法做到这一点,所以在这里我向您展示我给出的代码,请帮助我找到解决方案

 package com.example.hole;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;


public class MainActivity extends Activity {

ImageView view;
AnimationDrawable frameAnimation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 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.ass);
// 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();

}
}
}

最佳答案

您可能想要设置 AnimationListener通过在 onCreate 方法中调用方法 frameAnimation.setAnimationListener() 来添加动画。

关于java - 可绘制动画结束时进入新 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20444793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com