Passing values between screens [duplicate]

1

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

    
asked by anonymous 19.10.2017 / 18:55

2 answers

1

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

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

To receive the parameter on the second screen, in the onCreate event, place 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 replace them with your.

    
19.10.2017 / 19:09
0

You can create a public static string that receives the value and call in the next window, it's very simple.

example:

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

to call her:

string valor = main.name;
    
19.10.2017 / 19:00