Hi everybody I am trying to do animation with drawable animation
class....I am able do it with xml file.But i wanted to do it with
code.But it's not working.Only the first image is getting displayed.No
animation happens.Please tell me what wrong i m doing??
public class animation extends Activity {
/** Called when the activity is first created. */
protected Drawable anim1,anim3,anim2;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img=new ImageView(this);
LinearLayout l1=new LinearLayout(this);
AnimationDrawable frameAnimation=new AnimationDrawable();
System.out.println("####"+frameAnimation.toString()+"####");
this.anim1 = this.getResources().getDrawable
(R.drawable.test2);
this.anim3 = this.getResources().getDrawable
(R.drawable.test3);
this.anim2 = this.getResources().getDrawable
(R.drawable.test4);
frameAnimation.addFrame(anim3, 500);
frameAnimation.addFrame(anim1, 500);
frameAnimation.addFrame(anim2, 500);
System.out.println("#######"+frameAnimation.isRunning()
+"##########");
img.setBackgroundDrawable(frameAnimation);
frameAnimation.start();
System.out.println("###no of
frames"+frameAnimation.getNumberOfFrames()+"####");
setContentView(img);
System.out.println("#######"+frameAnimation.isRunning()
+"##########");
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---