0

As the step value of a variable of an Activity for a TextView other Activity? Can Help?

Thank you!

Screenshot of the emulator with hand-drawn circle and arrow ((See explanation on the picture))

Paul
  • 10,381
  • 13
  • 48
  • 86
digo
  • 45
  • 1
  • 1
  • 7
  • Possible duplicate of [How to pass value of one TextView to another TextView in different Activity](http://stackoverflow.com/questions/10023694/how-to-pass-value-of-one-textview-to-another-textview-in-different-activity) – Angel Koh Apr 18 '16 at 00:59

3 Answers3

0
Intent activityTwo = new Intent(this, Activity2.class);
activityTwo.putIntExtra("key", sumSettlement);
startActivity(activityTwo);

Now, in Activity2:

if(getIntent() != null) {
    textView.setText(String.valueOf(getIntent.getExtra("key"));
}
George Mulligan
  • 11,813
  • 6
  • 37
  • 50
YakuZa
  • 516
  • 7
  • 12
0

You can use of local broadcast receiver.

First register receiver in Activity B

  //in onCreate Method 
  LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
                    new IntentFilter("my-event-name"));


// It will be called whenever an Intent
// with an action named "my-event-name" is broadcasted.

 private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
 @Override
 public void onReceive(Context context, Intent intent) {
    // Get extra data included in the Intent
     String message = intent.getStringExtra("message");
   // show this message in textview 
 }
};

In Activity A

//broadcast this 
Intent intent = new Intent("my-event-name");
intent.putExtra("message", Integer(sumSettlment).toString());
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
Dharmaraj
  • 1,256
  • 13
  • 12
0

the easiest way is to use Intent: in first Activity

Intent intent =new Intent(CurrentClass.this,DisClass.class);
intent.putExtra("myTextValue",textView.getText().toString());
startActivity(intent);

in the dist activity do the following :

String myValue=getIntent().getExtra().getString("myTextValue");
textView.setText(myValue);
Basil Battikhi
  • 2,638
  • 1
  • 18
  • 34