0

I have a class MainActivity.java associated with a layout activity_main.xml. In this layout I have a TextView whose id is "textView". I have a second Activity called SecondActivity.java and in this Activity I have a Button. When I click the button, I want to set the text of the TextView in the MainActivity. How can I do this ? The simple:

TextView textView = (TextView) findViewById(R.id.textView);
textView.setText("Some Text");

doesn't seem to work...

codeMagic
  • 44,549
  • 13
  • 77
  • 93
Marc
  • 39
  • 3

1 Answers1

0

One Way :

When you click the button use a "SharedPreference" to save an indicator/condition/state.

In onResume of the main activity check the state and update your text.

mjstam
  • 1,049
  • 1
  • 6
  • 5