1
您好,這裏我已經嘗試在可繪製動畫完成後開始一個活動,但是我無法做到這一點,所以我在這裏向您展示我給出的代碼,請幫助我找到解掉當可繪製動畫結束時進行新活動
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();
}
}
}