Reputation: 488
How can I use the text in textview in one fragment in mainactivity from another fragment in another activity(activity_main2) .
Upvotes: 1
Views: 62
Reputation: 711
You can pass extras between activities.
Then, in your MainActivity, add:
Intent intent = new Intent(getBaseContext(), Activity_main2.class);
intent.putExtra("EXTRA_KEY_TEXT", "myText");
startActivity(intent);
And add to your Activity_main2:
String textFromMainActivity = getIntent().getStringExtra("EXTRA_KEY_TEXT");
Hope it helps you!
Upvotes: 1