I have made an animation using AnimationDrawable with images.It is running well. But I want to stop it after 2 repeat. How can I do this? Here is my codes.
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
imageViewCark.setBackgroundResource(R.drawable.anim);
animation = (AnimationDrawable) imageViewCark.getBackground();
if(hasFocus == true){
animation.start();
}else{
imageViewCark.setVisibility(ImageView.VISIBLE);
animation.stop();
}
}