Passing values between screens

Asked

Viewed 54 times

1

I would like a help, I’m new in android development and I’m trying to develop an app. Basically I will need 4 "screens" where the 1 is typed a value, goes to the next, in this "screen" chooses an option and goes to the next, depending on the selected option, loads options, in this 3 "screen", choose an option or type a value and goes to the next "screen" and in this 4 "screen" shows a result taking the chosen values or typed in the previous screens. I need what I should do and what steps, classes, etc I need to use.

2 answers

1


Luciano, to send a data to another screen use the following command in the call of the next screen:

 Intent mIntent = new Intent(context, SegundaTela.class);
                mIntent.putExtra("parametro_1", 2);
                mIntent.putExtra("parametro_2", 500);
                startActivity(mIntent);
                finish();

To receive the parameter in the second screen, in the onCreate event, put the following command:

private int tipo;
private int valor;

tipo = getIntent().getIntExtra("parametro_1", 1);
valor = getIntent().getIntExtra("parametro_2", 10);

Remembering, that the parameter name is case sensitve and the variables type and value, I used as an example, you can substitute for your.

0

You can create a publish static string that takes the value and call in the next window, it’s quite simple.

example:

public class main{public static string name ="";}

to call her:

string valor = main.name;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.