Hi again everyone and thanks for your help last time. Thanks also for any help you all give me on this one!
So i have an amimationDrawable
of a coinSpinning.
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/coinflip1" android:duration="25" />
<item android:drawable="@drawable/coinflip2" android:duration="25" />
<item android:drawable="@drawable/coinflip3" android:duration="25" />
<item android:drawable="@drawable/coinflip4" android:duration="25" />
<item android:drawable="@drawable/coinflip5" android:duration="25" />
<item android:drawable="@drawable/coinflip6" android:duration="25" />
<item android:drawable="@drawable/coinflip7" android:duration="25" />
<item android:drawable="@drawable/coinflip8" android:duration="25" />
<item android:drawable="@drawable/coinflip9" android:duration="25" />
<item android:drawable="@drawable/coinflip10" android:duration="25" />
<item android:drawable="@drawable/coinflip11" android:duration="25" />
<item android:drawable="@drawable/coinflip12" android:duration="25" />
</animation-list>
this is my method that spins the coin after a button onClick
public void spinCoin(){
final ImageView coinAmina = (ImageView) findViewById(R.id.imageView1);
coinAmina.setBackgroundResource(R.anim.coin_spin_heads);
coinAmina.post(new Runnable() {
@Override
public void run() {
frameAnimation = (AnimationDrawable) coinAmina.getBackground();
frameAnimation.start();
}
});
//end of coin spin
}
i also have AnimationDrawable frameAnimation;
before onCreate
it runs fine, but my problem has been trying to run it a certain amount of time eg 3
ive tried to loop the coinSpin()
then frameAnimation.stop
but no good
ive also tryed Thread.sleep(500)
with setOneShot(false)
then changed to true
after the sleep
all i want to do is run the animation whatever amount of time i like. other problem is when i have 2 coins to spin only one does but that should be another question
i understand setOneshot(true)
runs it once and false
runs it over and over...but how do i stop it
any help would be greatly appriciated