Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 11, 2019 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/4fb851744a6d0ff575e74c8dc33500bc to your computer and use it in GitHub Desktop.
Save parzibyte/4fb851744a6d0ff575e74c8dc33500bc to your computer and use it in GitHub Desktop.
package me.parzibyte.ventaconiva;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class Actividad2 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_actividad2);
// Obtener referencia
TextView textView1 = findViewById(R.id.textView),
textView2 = findViewById(R.id.textView2),
textView3 = findViewById(R.id.textView3);
// Recuperar valores
Intent intent = getIntent();
// El defaultValue es lo que se regresa si no se encuentra valor con la clave especificada
double totalBruto = intent.getDoubleExtra("totalBruto", 0);
double totalIva = intent.getDoubleExtra("totalIva", 0);
double totalNeto = intent.getDoubleExtra("totalNeto", 0);
// Ahora preparamos unos mensajes para ponerlos en los TextView
String mensajeTotalBruto = "Bruto: " + totalBruto;
String mensajeTotalIva = "IVA: " + totalIva;
String mensajeTotalNeto = "Neto: " + totalNeto;
// Finalmente le ponemos ese mensaje a cada TextView
textView1.setText(mensajeTotalBruto);
textView2.setText(mensajeTotalIva);
textView3.setText(mensajeTotalNeto);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment