Add this onClick event handler to the
MainActivity class:
public void onClick(View view) {
RadioButton radSpade = (RadioButton) findViewById(R.id.rad_spade);
RadioButton radHeart = (RadioButton) findViewById(R.id.rad_heart);
RadioButton radDiamond = (RadioButton) findViewById(R.id.rad_diamond);
RadioButton radClub = (RadioButton) findViewById(R.id.rad_club);
ImageView imgSuit = (ImageView) findViewById(R.id.img_suit);
int image = 0;
if(radSpade.isChecked( )) {
image = R.drawable.spade;
}
else if(radHeart.isChecked( )) {
image = R.drawable.heart;
}
else if(radDiamond.isChecked( )) {
image = R.drawable.diamond;
}
else if(radClub.isChecked( )) {
image = R.drawable.club;
}
imgSuit.setImageResource(image);
}