-2
So I have a value stored in a text view of a previous calculation in Activity 1 and I need that value in Activity 2 to perform other calculations. Pass only the value in String I can pass, what I can’t do is convert to double and do the calculations. There is and when I tried to double as well as be in the images the code is working, but the value that is appearing and the value 2 that sets in default value.
Follow the source codes.
Code of Activity 1:
public void padiola (View v){
Intent telapad = new Intent(this,Padiola.class);
telapad.putExtra("chavea",vua.getText().toString());
telapad.putExtra("chaveb",vub.getText().toString());
startActivity(telapad);
}
}
Code of Activity 2:
TextView qtda, qtdb, alta, altb, vuar, vubr;
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_padiola);
qtda = (TextView) findViewById(R.id.qtdPadareia);
qtdb = (TextView) findViewById(R.id.qtdPadbrita);
alta = (TextView) findViewById(R.id.altAreia);
altb = (TextView) findViewById(R.id.altBrita);
vuar = (TextView) findViewById(R.id.novoVA);
vubr = (TextView) findViewById(R.id.novoVB);
Double va = getIntent().getDoubleExtra("chavea",2f);
Double vb = getIntent().getDoubleExtra("chaveb",2f);
vuar.setText(Double.toString(va));
vubr.setText(Double.toString(vb));
}
public void trintaxquarenta(View v) {
//Para Areia//
double s1 = Double.parseDouble(vuar.getText().toString());
double s2 = Double.parseDouble(vubr.getText().toString());
double s3 = s1 + s2;
qtda.setText(Double.toString(s3));
}
}
Hello, all right? Kindly, Would you be able to post the codes instead of images? It would be more useful and practical.
– Péttrin Miranda
with you yes !!!
– IF12