package com.mycompany.myapp; import android.app.*; import android.os.*; import android.view.*; import android.widget.*; import android.content.*; public class MainActivity extends Activity { EditText ed1,ed2,ed3 ; double a,b,hasil ; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ed1 = (EditText)findViewById(R.id.ed1); ed2 = (EditText)findViewById(R.id.ed2); ed3 = (EditText)findViewById(R.id.ed3); Button btn = (Button) findViewById(R.id.bt1); btn setOnCreateContextMenuListener(this); } public void ambil(){ a = Integer.parseInt(ed1.getText().toString()); b = Integer.parseInt(ed2.getText().toString()); } public void kali(View v){ ambil(); hasil = a * b ; ed3.setText(hasil+""); } public void tambah(View v){ ambil(); hasil = a + b ; ed3.setText(hasil+""); } public void bagi(View v){ ambil(); hasil = a / b ; ed3.setText(hasil+""); } public void kurang(View v){ ambil(); hasil = a - b ; ed3.setText(hasil+""); } }