Drawable animation problem

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Drawable animation problem

Postby atishp04 » Thu Dec 18, 2008 5:53 am

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()+"##########");
}[marq=left]
atishp04
Freshman
Freshman
 
Posts: 3
Joined: Wed Dec 17, 2008 1:47 pm

Top

Postby andreleitao » Wed Mar 11, 2009 12:14 am

I tried hardly to use this class (but with no success!) I was going insane :lol: ... I could see that there were drawable objects inside the animation array, but they never appeared. :) I've searched for something on Google and I read some mails saying that there is no complete support for this yet (BUGGGG) :( . You can try to construct your own animation logic with individual drawables. Do it. Don't waste your time for now with AnimationDrawable class. :)
andreleitao
Experienced Developer
Experienced Developer
 
Posts: 70
Joined: Tue Mar 10, 2009 9:56 pm
Location: Recife - Brazil

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 4 guests