// ShowSuit Example // Source code file: MainActivity.java package it372.showsuit; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.RadioButton; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } 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); } }