i want that an image randomize if its the right image, if its not, finish the activity my code are working with next images, i mean, i dont know if its the right or wrong image for me to choose the option i want
ImageButton diferente = (ImageButton) findViewById(R.id.imgb2);
diferente.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int[] cards1 = {R.drawable.bg, R.drawable.bg1, R.drawable.a01, R.drawable.a02};
Random t = new Random();
int m = t.nextInt(4);
ImageView imgview2 = (ImageView) findViewById(R.id.imgv1);
imgview2.setImageResource(cards1[m]);
if ((cards1[m] == R.drawable.bg) || (cards1[m] == R.drawable.bg1)) {
imgview2.setImageResource(cards1[m]);
} else {
finish();
}
}
});
i just want to randomize the image if the image is on the "if" condition, not try to guess what image comes next
Aucun commentaire:
Enregistrer un commentaire