I'm a beginner of Java. Since I wanted to retrieve back the EditText value from Expenses class, I used the Intent Class
to store the data and then retrieve it in the Result
class. But when I run the Eclipse program, it stops.
Expenses class
builder.setPositiveButton("Add",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
if(s.equals("Food")){
value = et1.getText().toString();
food = Integer.parseInt(value);
description = et2.getText().toString();
categorySelected = true;
i.putExtra("eFood",food);
et1.getText().clear();
et2.getText().clear();
}
}
Result class
TextView tv;
int eFood;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Intent i = getIntent();
tv = (TextView)findViewById(R.id.textView2);
eFood = i.getIntExtra("eFood",0);
tv.setText(eFood);
}