You cannot change the Bitmap associated with a BitmapDrawable. On Sun, May 3, 2009 at 12:04 AM, ayush <[email protected]> wrote: > > i'm trying to use an AnimationDrawable for frame wise animation. the > problem is that when i render it on screen, only the first image in > the Drawable is displayed. the animationDrawable.isRunning() returns > true, however the images are not animated. > > following is the XML file (called whitepawnchanged.xml) and is stored > in the res/anim folder > > <?xml version="1.0" encoding="UTF-8"?> > <animation-list xmlns:android="http://schemas.android.com/apk/res/ > android" android:oneshot="false" android:id="@+id/upgradewhite"> > <item android:drawable="@drawable/whitebishop" > android:duration="100" /> > <item android:drawable="@drawable/whiteknight" > android:duration="100" /> > <item android:drawable="@drawable/whiterook" android:duration="100" / >> > <item android:drawable="@drawable/whitequeen" android:duration="100" / >> > </animation-list> > > > the java code within the onCreate() method of the Activity is as > follows ... (the relevant snippet) > > public void onCreate(Bundle icicle) { > > super.onCreate(icicle); > . > . > ImageView whitePawnChange = new ImageView(this); > whitePawnChange.setBackgroundResource(R.anim.whitepawnchange); > whiteChange = (AnimationDrawable)whitePawnChange.getBackground > (); //whiteChange is an AnimationDrawable object defined in the > Activity) > > //rest of the stuff > } > > the call to the whiteChange.start() is NOT in the onCreate and is > fired later when a button is clicked ... typically well after the > application is running. > apparently other people have faced this same issue but i could not > find any solution. any help would be greatly appreciated. > > incidentally, i'm also looking at a workaround (in case this problem > persists) - is there any way that we can change the Bitmap associated > with a BitmapDrawable AFTER the BitmapDrawable has been created? in > the documentation i could only find a getBitmap() method and nothing > along the lines of a setBitmap() or similar method. > > ~thanks > > > > > >
-- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

