简体   繁体   中英

How can you setText of a TextView in another TextView?

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"

?

Get the text of TextView1 with getText() and set it to the TextView2 as follows...

TextView1.setText("hello");

TextView2.setText(TextView1.getText())

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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM