I am trying to create an animation drawable that will simply have two frames and loop on the screen.
However, for some reason my Animationdrawable isn't doing even one round and just showing the first frame, Not to mention the looping...
Here is my code:
Handler handler = new Handler();
AnimationDrawable mouseani = new AnimationDrawable();
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Drawable mouse1 = getResources().getDrawable(R.drawable.mouse_for_use);
Drawable mouse2 = getResources().getDrawable(R.drawable.mouse_for_use_2);
mouseani.addFrame(mouse1, 500);
mouseani.addFrame(mouse2, 500);
img = (ImageView) findViewById(R.id.imgView);
img.setBackgroundDrawable(mouseani);
mouseani.setCallback(img);
mouseani.setVisible(true, true);
mouseani.start();
mouseani.stop();
}
Thanks!