I'm looking to create a running total on my MainActivity.java, this will be done through adding integers calculated in ActivityAdd.java then sending them across onClick save to a TextView in the MainActivity.java.
Any advice on how i would do this? it currently sends the values but doesn't consider adding the value to an existing value. it just removes the old with the new. thanks for your time, find my code below.
ActivityAdd.Java
OnClickListener button02OnClickListener =
new OnClickListener(){
@Override
public void onClick(View v) {
TextView et1 = (TextView)findViewById(R.id.textView4);
String theText = et1.getText().toString();
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
intent.putExtra("calorie", theText);
startActivity(intent);
}};
ActivityMain.Java
String calorie = getIntent().getStringExtra("calorie");
TextView textView1 = (TextView)findViewById(R.id.TextView1);
textView1.setText(calorie);
Aucun commentaire:
Enregistrer un commentaire