TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

O ANDROID CALCULADORA

Por:   •  13/6/2015  •  Trabalho acadêmico  •  1.392 Palavras (6 Páginas)  •  266 Visualizações

Página 1 de 6

XML (String)

    ContinuacaoCalculadora

    Hello world!

    Settings

    num1

    num2

    calcular

-----------------------------------------------------------------------------------

Main Activity (Java)

package firstaula.com.aula1.MainActivity;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.Toast;

public class MainActivity extends Activity {

        private double num1, num2, soma;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

                

                  Button btnCalcular = (Button) findViewById(R.id.btnCalcular);

               

               btnCalcular.setOnClickListener(new  OnClickListener() {

                        

                        @Override

                        public void onClick(View v) {

                                

                                EditText PrimeiroNumero = (EditText) findViewById(R.id.edt_num1);

                                EditText SegundoNumero = (EditText) findViewById(R.id.edt_num2);

                                

                                try {

                                        num1 = Double.parseDouble(PrimeiroNumero.getText().toString());

                                        num2 = Double.parseDouble(SegundoNumero.getText().toString());

                                        soma = num1 + num2;

                                        

                                        Toast.makeText(getBaseContext(), "A some e: " +soma, Toast.LENGTH_SHORT).show();

                                        

                                }catch(Exception erro){

                                        Toast.makeText(getBaseContext(), "Vc errou seu burro"+ erro, Toast.LENGTH_SHORT).show();

                                }

                        

                                

                                

                        }

                });

        }

        

        

}

-----------------------------------------------------------------------------------

public class Resultado extends Activity {

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_resultado);

}

public void clickBtnNovaTela(){

        Intent it = new Intent(Resultado.this,           Pagina_Resultado.class);

        startActivity(it);

        setContentView(R.layout.activity_pagina_resultado)

        android:id="@+id/imageBotao1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginLeft="22dp"

        android:src="@drawable/gauge"

        android:onClick="clickBtnNovaTela"

        android:background="@color/Yellow" />

-----------------------------------------------------------------------------------

...

Baixar como (para membros premium)  txt (5.3 Kb)   pdf (45 Kb)   docx (13.6 Kb)  
Continuar por mais 5 páginas »
Disponível apenas no TrabalhosGratuitos.com