Reputation: 487
I think this is a kind of special case question. But I need to get the answer. To be clear let me give an example:
Lets say I have an activity and a layout which belongs to that activity. Also I have a second activity and a layout. Here is the question:
Can I assign a text to the textview on second activity, by adding some code to first activity? I mean by using first activity, can I make changes on second activity's layout?
Thanks in advance guys.
Upvotes: 1
Views: 584
Reputation: 1094
if I understand you clearly, you can use "putextra" to send your data to the 2nd activity. And handle it when the other activity opened
Upvotes: 0
Reputation: 1646
Can you take input from the first activity, and when starting the second activity, pass whatever string you need in as an extra bundle on the launching intent?
Ala,
Intent intent = new Intent(this, Activity2.class)
intent.putExtra("TEXT", "string to pass to activity 2")
startActivity(intent)
in activity2's on create
String text = getIntent().getStringExtras("TEXT");
mTextView.setText(text);
Upvotes: 1