Animation for button does'nt working

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

Animation for button does'nt working

Postby sebasx » Thu Jan 05, 2012 6:13 pm

Hello,

I try add animation for button, I try use own, xml file

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
  2.     <item android:drawable="@drawable/cat" android:duration="200" />
  3.     <item android:drawable="@drawable/catakt" android:duration="200" />
  4.     <item android:drawable="@drawable/cat" android:duration="200" />
  5.     <item android:drawable="@drawable/catakt" android:duration="200" />
  6.     <item android:drawable="@drawable/cat" android:duration="200" />
  7.     <item android:drawable="@drawable/catakt" android:duration="200" />
  8.     <item android:drawable="@drawable/cat" android:duration="200" />
  9.     <item android:drawable="@drawable/catakt" android:duration="200" />
  10.     <item android:drawable="@drawable/cat" android:duration="200" />
  11.     <item android:drawable="@drawable/catakt" android:duration="200" />
  12. </animation-list>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


saved as catanim.xml
and use as setBackgroundResource(R.drawable.catanim);

That doesn't work

I try also code like here

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         animation = new AnimationDrawable();
  2.         animation.addFrame(getResources().getDrawable(R.drawable.cat), 3000);
  3.         animation.addFrame(getResources().getDrawable(R.drawable.catakt), 3000);
  4.         animation.addFrame(getResources().getDrawable(R.drawable.cat), 3000);
  5.         animation.addFrame(getResources().getDrawable(R.drawable.catakt), 3000);
  6.         animation.addFrame(getResources().getDrawable(R.drawable.cat), 3000);
  7.         animation.addFrame(getResources().getDrawable(R.drawable.catakt), 3000);
  8.         animation.setOneShot(false);
  9.        
  10.         animal1Button.setBackgroundDrawable(animation);
  11.         animation.setVisible(true, true);
  12.         animation.start();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


And animation for button still doean't work on Emulator and Device (both with Android 2.1 / API 7)

Please help
sebasx
Freshman
Freshman
 
Posts: 3
Joined: Thu Jan 05, 2012 6:07 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 3 guests