hey everyone hope u can help n thanks 4 looking
here is my code for 2 spinning coins, but only coin1 spins....is it because they both refrence the same xml animation file or something else?
public class MainActivity extends Activity {
static AnimationDrawable frameAnimation;
static AnimationDrawable frameAnimation2;
ImageView coinAnima2;
ImageView coinAnima;
public boolean currentSpin = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
coinAnima = (ImageView) findViewById(R.id.imageView1);
coinAnima2 = (ImageView) findViewById(R.id.imageView2);
Button bt = (Button) findViewById(R.id.button1);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//spinCoin();
spinCoin1();
spinCoin2();
}
});
}
//end of onCreate
public void spinCoin1(){
coinAnima = (ImageView) findViewById(R.id.imageView1);
coinAnima.setBackgroundResource(R.anim.coin_spin_heads);
new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
frameAnimation = (AnimationDrawable) coinAnima.getBackground();
frameAnimation.start();
}
});
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
frameAnimation.stop();
//end of run
}
//starts the thread
}).start();
//end of method
}
public void spinCoin2(){
coinAnima2 = (ImageView) findViewById(R.id.imageView2);
coinAnima2.setBackgroundResource(R.anim.coin_spin_heads);
new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
frameAnimation2 = (AnimationDrawable) coinAnima2.getBackground();
frameAnimation2.start();
}
});
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
frameAnimation2.stop();
//end of run
}
//starts the thread
}).start();
//end of method
}
//end of class
}
or should i have all the code for coins 1 and 2 in coinSpin1();
any help would be appriciated
previous questions were about only 1 coin....which people have helped but why when i add a second coin and spin 2 at once (not one after the other) the second coin doesnt do anything
should i put all the code in one method?