0

I try to show an animation (a windmills) inside each view of the ListView adapter, I can see the first image of the animation but the "animation" won't start.

Inside the adapter when I build the row, I start the animation like that:

           ImageView img = (ImageView) row.findViewById(R.id.loader);
           img.setVisibility(View.VISIBLE);
           img.setBackgroundResource(R.drawable.myanim);
           AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
           frameAnimation.start();

The animation myanim.xml work when it used outside a listview...

Thanks

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Maxime
  • 3,167
  • 7
  • 26
  • 33
  • Why are you using `setBackgroundResource()` instead of `setImageResource()`? – CommonsWare Nov 01 '11 at 14:42
  • if I use img.setImageResource(R.drawable.myanim); and AnimationDrawable frameAnimation = img.getDrawable(); it – Maxime Nov 01 '11 at 14:51
  • You might try switching to a plain `ListView` briefly to see if it works there. If it does, then it's a problem specific to `TouchListView`. If it fails with a plain `ListView`..., um, I have no idea. :-) – CommonsWare Nov 01 '11 at 14:55

1 Answers1

0

Actually Animation works when you are using event listeners.like button click.

Try to create button and give a

Button button=new Button();

button.performClick();

In Onclick method you have to start animation..

Ramesh Akula
  • 5,720
  • 4
  • 43
  • 67