Reputation: 714
I want the text I have in TextView1
to be displayed in TextView2
, for example:
TextView1.setText("hello");
TextView2.setText(ContentOf.TextView1)
What do I have to type instead of
"ContentOf.TextView1"
?
Upvotes: 1
Views: 92
Reputation: 9700
Get the text of TextView1
with getText()
and set it to the TextView2
as follows...
TextView1.setText("hello");
TextView2.setText(TextView1.getText())
Upvotes: 4
Reputation: 16364
TextView1.getText()
returns a CharacterSequence which is the text set in the corresponding TextView.
So,
TextView2.setText(TextView1.getText().toString());
Or even just,
TextView2.setText(TextView1.getText());
Upvotes: 1