Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <AbsoluteLayout
- android:id="@+id/widget0"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <EditText
- android:id="@+id/v1"
- android:layout_width="105dp"
- android:layout_height="39dp"
- android:textSize="16sp"
- android:layout_x="95dp"
- android:layout_y="47dp" />
- <EditText
- android:id="@+id/v2"
- android:layout_width="105dp"
- android:layout_height="39dp"
- android:textSize="16sp"
- android:layout_x="95dp"
- android:layout_y="86dp" />
- <TextView
- android:id="@+id/widget37"
- android:layout_width="wrap_content"
- android:layout_height="20dp"
- android:text="valor1"
- android:layout_x="27dp"
- android:layout_y="56dp" />
- <TextView
- android:id="@+id/widget37_copy"
- android:layout_width="wrap_content"
- android:layout_height="20dp"
- android:text="valor2"
- android:layout_x="27dp"
- android:layout_y="92dp" />
- <Button
- android:id="@+id/soma"
- android:layout_width="60dp"
- android:layout_height="42dp"
- android:text="+"
- android:layout_x="31dp"
- android:layout_y="175dp"
- android:onClick="somar"/>
- <Button
- android:id="@+id/subtrair"
- android:layout_width="58dp"
- android:layout_height="43dp"
- android:text="-"
- android:layout_x="97dp"
- android:layout_y="175dp"
- android:onClick="subtrair"/>
- <Button
- android:id="@+id/div"
- android:layout_width="57dp"
- android:layout_height="42dp"
- android:text="/"
- android:layout_x="160dp"
- android:layout_y="175dp"
- android:onClick="divisao"/>
- <Button
- android:id="@+id/vezes"
- android:layout_width="57dp"
- android:layout_height="42dp"
- android:text="*"
- android:layout_x="228dp"
- android:layout_y="175dp"
- android:onClick="vezes"/>
- </AbsoluteLayout>
- ///////////
- package android.app;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.EditText;
- import android.widget.Toast;
- public class MainActivity extends Activity {
- private EditText edtValor1;
- private EditText edtValor2;
- /**
- * Called when the activity is first created.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- edtValor1 = (EditText) findViewById(R.id.v1);
- edtValor2 = (EditText) findViewById(R.id.v2);
- }
- public void onClick(View v) {
- }
- public void subtrair(View v) {
- double valor1 = Double.parseDouble(edtValor1.getText().toString());
- double valor2 = Double.parseDouble(edtValor2.getText().toString());
- double result = valor1 - valor2;
- Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
- }
- public void somar(View v) {
- double valor1 = Double.parseDouble(edtValor1.getText().toString());
- double valor2 = Double.parseDouble(edtValor2.getText().toString());
- double result = valor1 + valor2;
- Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
- }
- public void divisao(View v) {
- double valor1 = Double.parseDouble(edtValor1.getText().toString());
- double valor2 = Double.parseDouble(edtValor2.getText().toString());
- double result = valor1 / valor2;
- Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
- }
- public void vezes(View v) {
- double valor1 = Double.parseDouble(edtValor1.getText().toString());
- double valor2 = Double.parseDouble(edtValor2.getText().toString());
- double result = valor1 * valor2;
- Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
- }
- }
- //////////////////////////////////////////////CALCULADORA
- http://professoroscarjr.blogspot.com.br/p/tecmob.html
- http://www.devmedia.com.br/projetando-e-criando-aplicativos-para-dispositivos-moveis/30671
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement