1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| public class MainActivity extends ActionBarActivity {
private final static Random random = new Random();
private Button next;
private ImageView cardImage,cardImage2;
int currentCardIndex = 0;
int[] cards = {
R.drawable.h2,
R.drawable.h3,
R.drawable.h4,
R.drawable.h5,
R.drawable.h6,
R.drawable.h7,
R.drawable.h8,
R.drawable.h9,
R.drawable.h10,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout root = (LinearLayout) findViewById(R.id.clickscreen);
shuffle(cards);
next = (Button)findViewById(R.id.button1);
cardImage = (ImageView)findViewById(R.id.cards);
final Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.abc_slide_in_top);
new Dialog(getApplicationContext());
final MediaPlayer mp = MediaPlayer.create(this, R.raw.siren);
final MediaPlayer card = MediaPlayer.create(this, R.raw.cardflip);
root.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
cardImage.startAnimation(fadeInAnimation);
cardImage.setImageResource(cards[currentCardIndex++]);
card.start();
if (cardImage.getDrawable().getConstantState().equals(getResources().getDrawable(R.drawable.ta).getConstantState())){
AlertUtil.messageAlert(MainActivity.this,getString(R.string.cul_sec) , getString(R.string.cul_sec_regle));
}
if (cardImage.getDrawable().getConstantState().equals(getResources().getDrawable(R.drawable.sa).getConstantState())){
AlertUtil.messageAlert(MainActivity.this,getString(R.string.cul_sec), getString(R.string.cul_sec_regle));
}
if (cardImage.getDrawable().getConstantState().equals(getResources().getDrawable(R.drawable.ha).getConstantState())){
AlertUtil.messageAlert(MainActivity.this,getString(R.string.cul_sec), getString(R.string.cul_sec_regle));
} |
Partager