Facebook
From Blush Marten, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 229
  1. package pt.ubi.di.pmd.acalculator;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.*;
  6. import android.widget.*;
  7.  
  8. public class ACalculator extends Activity {
  9.     EditText oTEdit1 ;
  10.     EditText oTEdit2 ;
  11.     Button oButton ;
  12.     TextView oTView1;
  13.  
  14.  
  15.  
  16.     @Override
  17.     protected void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.activity_acalculator);
  20.         oTEdit1 = ( EditText ) findViewById(R. id .number1) ;
  21.         oTEdit2 = ( EditText ) findViewById(R. id .number2) ;
  22.         oButton = (Button) findViewById(R. id .SUM) ;
  23.         oTView1 = (TextView) findViewById(R. id . result ) ;
  24.  
  25.         oButton.setOnClickListener (
  26.                 new View.OnClickListener ()
  27.                 { public void onClick (View oView)
  28.                 {
  29.                     double d1 = (new Double(oTEdit1 . getText () . toString () ) ) . doubleValue () ;
  30.                     double d2 = (new Double(oTEdit2 . getText () . toString () ) ) . doubleValue () ;
  31.                     double dSum = d1 + d2;
  32.                     String dSum1=dSum.ToString();
  33. oTView1.setText(dSum);
  34.                 }
  35.                 }) ;
  36.     }
  37.  
  38.  
  39.  
  40.  
  41. }
  42.  
  43.  
  44.