title: How to format double variables to two decimal places?
body: <p>I have used the decimal format class to set the editText variables to my format variables <code>mark1Format</code>.But I'm not sure how to set the new format variables to this <code>result1 = (EditText)findViewById(R.id.mark1);</code> I mean setting the format variables to the R.id.mark1Format.Anyone have a solution here?</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.result);
          result1 = (EditText)findViewById(R.id.mark1);
          result2 = (EditText)findViewById(R.id.mark2);
  
  
          Intent intent = getIntent();
          double mark1 = intent.getDoubleExtra("number1", 0);
          double mark2 = intent.getDoubleExtra("number2", 0);
  
        //format to two decimal places
          DecimalFormat df = new DecimalFormat("#.00");
          String mark1Format = df.format(mark1);
          String mark2Format = df.format(mark2);
  
  
          //set the variables on EditTexts like this :
          result1 = (EditText)findViewById(R.id.mark1);
          result2 = (EditText)findViewById(R.id.mark2);
          result1.setText(mark1+"");
          result2.setText(mark2+"");
      }
  </code></pre>