title: print a string in EditText box Android
body: <p>I am writing a simple program to calculate the unknown from the Chemistry formula PV=nRT.
  R is a constant 8.31.</p>
  
  <p>Users can input 3 pieces of data (from 4 possible edit text boxes) and choose what they want to calculate from radio buttons.  I have put in a fail safe, so if the box is blank then standard conditions are used.  I have worked out how to calculate the answer for each case, but not to display it in the appropriate text box.</p>
  
  <p>Here is the XML layout</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" &gt;
  
      &lt;EditText
          android:id="@+id/editText4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText3"
          android:layout_below="@+id/editText3"
          android:layout_marginTop="27dp"
          android:ems="10" /&gt;
  etc x 4
  
  
      &lt;RadioGroup
          android:id="@+id/radioGroup1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_alignTop="@+id/button1"
          android:layout_marginRight="33dp" &gt;
  
          &lt;RadioButton
              android:id="@+id/radio0"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:checked="true"
              android:text="@string/pressure" /&gt;
  etc x 4
      &lt;/RadioGroup&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is the script from the java class:</p>
  
  <pre><code>     public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_main);
                    pressure = (EditText) findViewById(R.id.editText1);
                    volume = (EditText) findViewById(R.id.editText2);
                    moles = (EditText) findViewById(R.id.editText3);
                    temperature= (EditText) findViewById(R.id.editText4);
  
                    return; }
  
  
                    public void onClick(View view) { 
                           switch (view.getId()) { 
                    case R.id.button1:
                           RadioButton pressureButton = (RadioButton)
                                 findViewById(R.id.radio0); 
                    RadioButton volumeButton = (RadioButton) 
                                 findViewById(R.id.radio1); 
                    RadioButton molesButton = (RadioButton) 
                                 findViewById(R.id.radio2);
                    RadioButton temperatureButton = (RadioButton) 
                                 findViewById(R.id.radio3); 
                    return;
                           }
                    float pressuren = Float.parseFloat(pressure.getText().toString());
                    float volumen = Float.parseFloat(volume.getText().toString());
                    float molesn = Float.parseFloat(moles.getText().toString());
                    float temperaturen = Float.parseFloat(temperature.getText().toString());
  
               //to allow for blank editText boxes
  
                    if (pressuren == 0) {pressuren = 100000;
                                 }
                    if (volumen == 0) {volumen = (float)0.0247;
                                 }
                    if (molesn == 0) {molesn= 1;
                                 }
                    if (temperaturen == 0) {temperaturen = 298;
  
                    }
  
               //to calculate pressure
  
                   if (pressureButton.isChecked()) {
                             float pressans = (float) (molesn * 8.31 * temperaturen ) / volumen;
                   float volans = (float) volumen;
                   float moleans = (float) molesn;
                   float temperaturans = (float) temperaturen;
                   }
  etc x 4
  </code></pre>
  
  <p>Sorry for all the code, </p>
  
  <p>I would like to display pressurans in the editText1 box etc</p>
  
  <p>Any help greatly appreciated.</p>