programa 2

2
PROGRAMA 2 Package com.example.programa2; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public void sumar(View view){ EditText et1=(EditText) findViewById (R.id.num1);

Upload: joselyn-aguirre

Post on 29-Jul-2015

14 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Programa 2

PROGRAMA 2

Package com.example.programa2;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.view.View;

import android.widget.TextView;

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

public void sumar(View view){

EditText et1=(EditText) findViewById (R.id.num1);

EditText et2=(EditText) findViewById (R.id.num2);

TextView sol=(TextView) findViewById (R.id.res);

Page 2: Programa 2

double n1=Double.parseDouble(et1.getText().toString());

double n2=Double.parseDouble(et2.getText().toString());

double r;

r=n1+n2

sol.setText(String.valueOf("El resultado de"+n1+"+"+n2+" = "+r));

}

}