Waqas Aamir

Waqas Aamir

  • NA
  • 3
  • 754

integer variable value of one activity in another activity

May 29 2015 9:35 AM
i want to store integer variable value of one activity in integer variable of another activity. code is this... its giviing errors. first activity class is this.....
public class areaActivity extends Activity {
 code portion is this...
Button movenextarea=(Button) findViewById(R.id.buttonnextexteriorwall);
movenextarea.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText areanumber1 = (EditText) findViewById(R.id.editTextplotarea);
int plotarea1 = Integer.parseInt(areanumber1.getText().toString());
EditText areanumber2 = (EditText) findViewById(R.id.editTextcoveredarea);
int coveredarea1 = Integer.parseInt(areanumber2.getText().toString());

double sqrt = (int) Math.sqrt(plotarea1);
oneside = plotarea1;

Intent secondActivity = new Intent (getApplicationContext(), roomActivity.class);
secondActivity.putExtra("oneside", oneside);
startActivity(secondActivity);

startActivity(new Intent(getApplicationContext(), exteriorwallActivity.class));
}

});
 
second activity name is this.
public class exteriorwallActivity extends Activity {
code portion is this..
Button nextactivity1 = (Button) findViewById(R.id.buttonfoundationtype);
nextactivity1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText exteriornumber1 = (EditText) findViewById(R.id.editTextinputlengthexterior);
int noofwalls1 = Integer.parseInt(exteriornumber1.getText().toString());
Intent intent = getIntent();
int newPlotarea1 = getIntent().getIntExtra("oneside", 0);
// int newPlotarea1 = getIntent().getExtras().getInt("NameOfVariable");
totallengthofwall = noofwalls * newPlotarea1;
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;

Toast toast = Toast.makeText(context,"Value is " + newPlotarea1, duration);
toast.show();
}

});