Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 11, 2019 03:52
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/94a0bfd4a04142084a1b8248112697f0 to your computer and use it in GitHub Desktop.
Save parzibyte/94a0bfd4a04142084a1b8248112697f0 to your computer and use it in GitHub Desktop.
package me.parzibyte.sumarnmeros;
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 los datos que nos pasaron. El 0 es por si no se nos pasara
// nada, ya que se necesita un valor por defecto (defaultValue)
Intent intent = getIntent();
int sumaQueNosPasaron = intent.getIntExtra("suma", 0);
// Obtener Widget de vista
TextView textView = findViewById(R.id.textView);
// Armar un mensaje
String mensaje = "La suma es: " + sumaQueNosPasaron;
// Y ponerle la suma
textView.setText(mensaje);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment