title: radio button happen only on a button click android studio
body: <p>Essentially, what I want is that once I click the Translate button, I want to print which radio button is currently checked. What I have right now is that as soon as I click a radio button, it prints it to the textview, but I want it to only happen once I click the Translate button. Any help would be greatly appreciated!</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
  
      public void Translate(View view) {
          onRadioButtonClicked(view);
  
      }
  
      public void onRadioButtonClicked(View view) {
          // Is the button now checked?
          boolean checked = ((RadioButton) view).isChecked();
  
          // Check which radio button was clicked
          switch(view.getId()) {
              case R.id.radio_hi:
                  if (checked) { display("hi"); }
                  break;
              case R.id.radio_bus:
                  if (checked) { display("bus"); }
                  break;
              case R.id.radio_bathroom:
                  if (checked) { display("bathroom"); }
                  break;
              case R.id.radio_beer:
                  if (checked) { display("beer"); }
                  break;
              case R.id.radio_cost:
                  if (checked) { display("cost"); }
                  break;
              default:
                  display("no button clicked");
          }
      }
  
  
  
      private void display(String str) {
          TextView translateTextView = (TextView) findViewById(R.id.display);
          translateTextView.setText(str);
      }
  }
  
  
  
  
  
  
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Translate"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:id="@+id/button"
          android:onClick="Translate"/&gt;
  
      &lt;RadioGroup
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:id="@+id/radioGroup"
          android:layout_below="@+id/spinner1"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_marginTop="37dp"&gt;
          &lt;RadioButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/radio_hi"
              android:text="@string/hi"
              android:onClick="onRadioButtonClicked"/&gt;
          &lt;RadioButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/radio_bus"
              android:text="@string/taxi"
              android:onClick="onRadioButtonClicked"/&gt;
          &lt;RadioButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/radio_bathroom"
              android:text="@string/bathroom"
              android:onClick="onRadioButtonClicked"/&gt;
          &lt;RadioButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/radio_beer"
              android:text="@string/beer"
              android:onClick="onRadioButtonClicked"/&gt;
          &lt;RadioButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/radio_cost"
              android:text="@string/cost"
              android:onClick="onRadioButtonClicked"/&gt;
      &lt;/RadioGroup&gt;
  </code></pre>