final AnimationDrawable ad = (AnimationDrawable) computerpic
.getBackground();
final AnimationDrawable ad1 = (AnimationDrawable) iv1.getBackground();
ad1.start();
ad.start();
reset.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
ad.start();
computerpic.setVisibility(View.VISIBLE);
computerpic1.setVisibility(View.INVISIBLE);
}
});
jiandao.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
ad.stop();
computerpic.setVisibility(View.INVISIBLE);
int x = (int) (Math.random() * 3);
if (x == 0) {
result.setText("平了");
computerpic1.setImageResource(pic[x]);
} else if (x == 1) {
result.setText("输了");
computerpic1.setImageResource(pic[x]);
} else if (x == 2) {
result.setText("赢了");
computerpic1.setImageResource(pic[x]);
}
computerpic1.setVisibility(View.VISIBLE);
}
});
shitou.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
ad.stop();
computerpic.setVisibility(View.INVISIBLE);
int x = (int) (Math.random() * 3);
if (x == 0) {
result.setText("赢了");
computerpic1.setImageResource(pic[x]);
} else if (x == 1) {
result.setText("平了");
computerpic1.setImageResource(pic[x]);
} else if (x == 2) {
result.setText("输了");
computerpic1.setImageResource(pic[x]);
}
computerpic1.setVisibility(View.VISIBLE);
}
});
bu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
ad.stop();
computerpic.setVisibility(View.INVISIBLE);
int x = (int) (Math.random() * 3);
if (x == 0) {
result.setText("输了");
computerpic1.setImageResource(pic[x]);
} else if (x == 1) {
result.setText("赢了");
computerpic1.setImageResource(pic[x]);
} else if (x == 2) {
result.setText("平了");
computerpic1.setImageResource(pic[x]);
}
computerpic1.setVisibility(View.VISIBLE);
}
});
}
}