package com.inforhomex.auditor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private EditText editText1;
private TextView textView;
private RadioButton radio1;
private RadioButton radio2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this,"Creando App",Toast.LENGTH_SHORT).show();
editText1 = (EditText) findViewById(R.id.editText1);
textView = (TextView) findViewById(R.id.textView);
radio1 =(RadioButton) findViewById(R.id.radioButton);
radio2 =(RadioButton) findViewById(R.id.radioButton2);
}
public void calculos(View view){
String valor = editText1.getText().toString();
String resultado = "";
if(radio1.isChecked()){
double celsius = (Double.parseDouble(valor) - 32 ) * 0.55555;
resultado = "Celsius = "+String.valueOf(celsius);
}
if(radio2.isChecked()){
double fahrenheit = (Double.parseDouble(valor) * 1.8) + 32;
resultado = "Fahrenheit = "+String.valueOf(fahrenheit);
}
Toast.makeText(this,resultado,Toast.LENGTH_SHORT).show();
textView.setText(resultado);
editText1.setText("");
}
@Override
protected void onStart(){
super.onStart();
Toast.makeText(this,"Iniciando App",Toast.LENGTH_SHORT).show();
}
@Override
protected void onResume(){
super.onResume();
Toast.makeText(this,"Resumiendo App",Toast.LENGTH_SHORT).show();
}
@Override
protected void onPause(){
super.onPause();
Toast.makeText(this,"Pausando App",Toast.LENGTH_SHORT).show();
}
@Override
protected void onStop(){
super.onStop();
Toast.makeText(this,"Deteniendo App",Toast.LENGTH_SHORT).show();
}
@Override
protected void onDestroy(){
super.onDestroy();
Toast.makeText(this,"Destruyendo App",Toast.LENGTH_SHORT).show();
}
}
Una simple calculadora de grados Ceslius o/y Fahrenheit con Android
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.